diff options
author | Eli Kogan-Wang <elikowa@gmail.com> | 2022-05-16 15:17:35 +0200 |
---|---|---|
committer | Eli Kogan-Wang <elikowa@gmail.com> | 2022-05-16 15:17:35 +0200 |
commit | 27d0f6747d7e70be4b9ade28ce77444e6135cadb (patch) | |
tree | 9691eb0d1da309a33e0faec689fd26baed1d4d65 /src/libexpr | |
parent | c81d24f1c70cc454c9a88cea70048d8563f60784 (diff) |
resolve redundant priority passing, wrap NixInt in eval-cache variant
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval-cache.cc | 6 | ||||
-rw-r--r-- | src/libexpr/eval-cache.hh | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc index bf811c8ed..6b3c27fd5 100644 --- a/src/libexpr/eval-cache.cc +++ b/src/libexpr/eval-cache.cc @@ -306,7 +306,7 @@ struct AttrDb case AttrType::Bool: return {{rowId, queryAttribute.getInt(2) != 0}}; case AttrType::Int: - return {{rowId, queryAttribute.getInt(2)}}; + return {{rowId, (int_t) queryAttribute.getInt(2)}}; case AttrType::ListOfStrings: return {{rowId, tokenizeString<std::vector<std::string>>(queryAttribute.getStr(2), "\t")}}; case AttrType::Missing: @@ -649,9 +649,9 @@ NixInt AttrCursor::getInt() if (!cachedValue) cachedValue = root->db->getAttr(getKey()); if (cachedValue && !std::get_if<placeholder_t>(&cachedValue->second)) { - if (auto i = std::get_if<NixInt>(&cachedValue->second)) { + if (auto i = std::get_if<int_t>(&cachedValue->second)) { debug("using cached Integer attribute '%s'", getAttrPathStr()); - return *i; + return (*i).x; } else throw TypeError("'%s' is not an Integer", getAttrPathStr()); } diff --git a/src/libexpr/eval-cache.hh b/src/libexpr/eval-cache.hh index ec255c60d..68b5952eb 100644 --- a/src/libexpr/eval-cache.hh +++ b/src/libexpr/eval-cache.hh @@ -52,6 +52,7 @@ struct placeholder_t {}; struct missing_t {}; struct misc_t {}; struct failed_t {}; +struct int_t { NixInt x; int_t(NixInt x) : x(x) {}; }; typedef uint64_t AttrId; typedef std::pair<AttrId, Symbol> AttrKey; typedef std::pair<std::string, NixStringContext> string_t; @@ -64,7 +65,7 @@ typedef std::variant< misc_t, failed_t, bool, - NixInt, + int_t, std::vector<std::string> > AttrValue; |