diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-08-16 08:57:47 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-16 08:57:47 +0800 |
| commit | 45d9961a6a86d184248ef84f6a07125b0c224f97 (patch) | |
| tree | c91d9b9aa722ceb727f7f1c8c2041d7d2bb13466 /source/slang/slang-check-decl.cpp | |
| parent | e34b005c47d265105e7bba509cadaa3e225237af (diff) | |
Use ankerl/unordered_dense as a hashmap implementation (#3036)
* Correct namespace for getClockFrequency
* missing const
* Add missing assignment operator
* Remove unused variables
* Return correct modified variable
* Use stable hash code for file system identity
* terse static_assert
* Structured binding for map iteration
* Make (==) and getHashCode const on many structs
* Add ConstIterator for LinkedList
* Replace uses of ItemProxy::getValue with Dictionary::at
* Extract list of loads from gradientsMap before updating it
* Const correctness in type layout
* Add unordered_dense hashmap submodule
* Use wyhash or getHashCode in slang-hash.h
* refactor slang-hash.h
* Use ankerl/unordered_dense as a hashmap implementation
Notable changes:
- The subscript operator returns a reference directly to the value,
rather than a lazy ItemProxy (pair of dict pointer and key)
slang-profile time (95% over 10 runs):
- Before: 6.3913906 (±0.0746)
- After: 5.9276123 (±0.0964)
* 64 bit hash for strings
So they have the same hash as char buffers with the same contents
* Narrowing warnings for gcc to match msvc
* revert back to c++17
* Correct c++ version for msvc
* Use path to unordered_dense which keeps tests happy
* Do not assign to and read from map in same expression
* Remove redundant map operations in primal-hoist
* Split out stable hash functions into slang-stable-hash.h
* 64 bit hash by default
* regenerate vs projects
* Correct return type from HashSetBase::getCount()
* correct width for call to Dictionary::reserve
* Use stable hash for obfuscated module ids
* Signed int for reserve
* clearer variable naming
* Parameterize Dictionary on hash and equality functors
* Allow heterogenous lookup for Dictionary
* missing const
* Use set over operator[] in some places
* Remove unused function
* s/at/getValue
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 6385e5f57..8c9ca2936 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -2006,11 +2006,11 @@ namespace Slang // Once things are done, we will install the satisfying values // into the witness table for the requirements. // - for( auto p : mapRequiredToSatisfyingAccessorDeclRef ) + for( const auto& [key, value] : mapRequiredToSatisfyingAccessorDeclRef ) { witnessTable->add( - p.key.getDecl(), - RequirementWitness(p.value)); + key.getDecl(), + RequirementWitness(value)); } // // Note: the property declaration itself isn't something that @@ -2559,10 +2559,10 @@ namespace Slang // if (auto typeParamDecl = as<DeclRefType>(constraintDecl->sub.type)->getDeclRef().as<GenericTypeParamDecl>().getDecl()) { - auto synTypeParamDecl = mapOrigToSynTypeParams[typeParamDecl]; + auto synTypeParamDecl = mapOrigToSynTypeParams.getValue(typeParamDecl); // Construct a DeclRefExpr from the type parameter. - auto synTypeParamDeclRef = makeDeclRef(synTypeParamDecl.getValue()); + auto synTypeParamDeclRef = makeDeclRef(synTypeParamDecl); auto synTypeParamDeclRefExpr = m_astBuilder->create<VarExpr>(); synTypeParamDeclRefExpr->declRef = synTypeParamDeclRef; @@ -3262,9 +3262,9 @@ namespace Slang // difference between our synthetic property and a hand-written // one with the same behavior. // - for(auto p : mapRequiredAccessorToSynAccessor) + for(auto& [key, value] : mapRequiredAccessorToSynAccessor) { - witnessTable->add(p.key.getDecl(), RequirementWitness(makeDeclRef(p.value))); + witnessTable->add(key.getDecl(), RequirementWitness(makeDeclRef(value))); } witnessTable->add(requiredMemberDeclRef.getDecl(), RequirementWitness(makeDeclRef(synPropertyDecl))); @@ -3531,7 +3531,6 @@ namespace Slang { case SynthesisPattern::AllInductive: { - int paramIndex = 0; for (auto arg : synArgs) { auto memberExpr = m_astBuilder->create<MemberExpr>(); @@ -3541,8 +3540,6 @@ namespace Slang memberExpr->name = varMember->getName(); paramFields.add(memberExpr); inductiveArgMask.add(true); - - paramIndex++; } break; } @@ -5460,9 +5457,8 @@ namespace Slang _addTargetModifiers(newDecl, newTargets); bool hasConflict = false; - for (auto& pair : newTargets) + for (auto& [target, value] : newTargets) { - Name* target = pair.key; auto found = currentTargets.tryGetValue(target); if (found) { @@ -6666,10 +6662,10 @@ namespace Slang void SharedSemanticsContext::_addCandidateExtensionsFromModule(ModuleDecl* moduleDecl) { - for( auto& entry : moduleDecl->mapTypeToCandidateExtensions ) + for( auto& [entryKey, entryValue] : moduleDecl->mapTypeToCandidateExtensions ) { - auto& list = _getCandidateExtensionList(entry.key, m_mapTypeDeclToCandidateExtensions); - list.addRange(entry.value->candidateExtensions); + auto& list = _getCandidateExtensionList(entryKey, m_mapTypeDeclToCandidateExtensions); + list.addRange(entryValue->candidateExtensions); } } |
