MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / bakeConstStringKey

Function bakeConstStringKey

src/ast/ast_simulate.cpp:127–133  ·  view source on GitHub ↗

Const-string table key: bake the key bytes (into the const-string heap) and their hash at simulate time so the runtime node skips the per-lookup hash_blockz64 walk. Returns the baked key char* (and sets outHash) when keyType is string and keyExpr is an ExprConstString; nullptr otherwise (caller falls back to the regular hashing node).

Source from the content-addressed store, hash-verified

125 // baked key char* (and sets outHash) when keyType is string and keyExpr is an ExprConstString;
126 // nullptr otherwise (caller falls back to the regular hashing node).
127 static __forceinline char * bakeConstStringKey ( Context & context, Expression * keyExpr,
128 const TypeDecl * keyType, uint64_t & outHash ) {
129 if ( keyType->baseType != Type::tString || !keyExpr->rtti_isStringConstant() ) return nullptr;
130 char * keyStr = context.constStringHeap->impl_allocateString(static_cast<ExprConstString*>(keyExpr)->getValue());
131 outHash = hash_blockz64((uint8_t *)keyStr);
132 return keyStr;
133 }
134
135 struct SimulateVisitor : Visitor {
136 Context & context;

Callers 1

visitMethod · 0.85

Calls 3

hash_blockz64Function · 0.85
getValueMethod · 0.80
impl_allocateStringMethod · 0.45

Tested by

no test coverage detected