yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Ellie Hermaszewskaformatf65d756bf

master
1.2 KiB48 linesraw
1#include "slang-string-slice-index-map.h"
2
3namespace Slang
4{
5
6// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! StringSliceIndexMap !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7
8StringSliceIndexMap::CountIndex StringSliceIndexMap::add(
9    const UnownedStringSlice& key,
10    Index valueIndex)
11{
12    StringSlicePool::Handle handle;
13    m_pool.findOrAdd(key, handle);
14    const CountIndex countIndex = StringSlicePool::asIndex(handle);
15    if (countIndex >= m_indexMap.getCount())
16    {
17        SLANG_ASSERT(countIndex == m_indexMap.getCount());
18        m_indexMap.add(valueIndex);
19    }
20    else
21    {
22        m_indexMap[countIndex] = valueIndex;
23    }
24    return countIndex;
25}
26
27StringSliceIndexMap::CountIndex StringSliceIndexMap::findOrAdd(
28    const UnownedStringSlice& key,
29    Index defaultValueIndex)
30{
31    StringSlicePool::Handle handle;
32    m_pool.findOrAdd(key, handle);
33    const CountIndex countIndex = StringSlicePool::asIndex(handle);
34    if (countIndex >= m_indexMap.getCount())
35    {
36        SLANG_ASSERT(countIndex == m_indexMap.getCount());
37        m_indexMap.add(defaultValueIndex);
38    }
39    return countIndex;
40}
41
42void StringSliceIndexMap::clear()
43{
44    m_pool.clear();
45    m_indexMap.clear();
46}
47
48} // namespace Slang