diff options
author | eldritch horrors <pennae@lix.systems> | 2024-03-08 05:37:19 +0100 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-03-09 00:25:54 -0700 |
commit | f7b2476415906097404532c7485622eb37cf17e0 (patch) | |
tree | 5b06eb44c4c6c8d35b1ad86811c88f570be89d7d /src/libexpr/eval.cc | |
parent | 92693973b6e059e9d6056cf6547cc66459efc580 (diff) |
don't repeatedly look up ast internal symbols
these symbols are used a *lot*, so it makes sense to cache them. this
mostly increases clarity of the code (however clear one may wish to call
the parser desugaring here), but it also provides a small performance
benefit.
(cherry picked from commit 09a1128d9e2ff0ae6176784938047350d6f8a782)
Change-Id: I73d9f66be4555168e048cb2d542277251580c2d1
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 2a6a89ddb..055c0ca3f 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -414,6 +414,16 @@ EvalState::EvalState( , sPath(symbols.create("path")) , sPrefix(symbols.create("prefix")) , sOutputSpecified(symbols.create("outputSpecified")) + , exprSymbols{ + .sub = symbols.create("__sub"), + .lessThan = symbols.create("__lessThan"), + .mul = symbols.create("__mul"), + .div = symbols.create("__div"), + .or_ = symbols.create("or"), + .findFile = symbols.create("__findFile"), + .nixPath = symbols.create("__nixPath"), + .body = symbols.create("body") + } , repair(NoRepair) , emptyBindings(0) , derivationInternal(rootPath(CanonPath("/builtin/derivation.nix"))) @@ -2815,7 +2825,7 @@ Expr * EvalState::parse( const SourcePath & basePath, std::shared_ptr<StaticEnv> & staticEnv) { - auto result = parseExprFromBuf(text, length, origin, basePath, symbols, positions); + auto result = parseExprFromBuf(text, length, origin, basePath, symbols, positions, exprSymbols); result->bindVars(*this, staticEnv); |