aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/symbol-table.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/symbol-table.hh')
-rw-r--r--src/libexpr/symbol-table.hh26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/libexpr/symbol-table.hh b/src/libexpr/symbol-table.hh
index c97a0a2db..967a186dd 100644
--- a/src/libexpr/symbol-table.hh
+++ b/src/libexpr/symbol-table.hh
@@ -10,15 +10,11 @@
namespace nix {
-/* Symbol table used by the parser and evaluator to represent and look
- up identifiers and attributes efficiently. SymbolTable::create()
- converts a string into a symbol. Symbols have the property that
- they can be compared efficiently (using an equality test),
- because the symbol table stores only one copy of each string. */
-
-/* This class mainly exists to give us an operator<< for ostreams. We could also
- return plain strings from SymbolTable, but then we'd have to wrap every
- instance of a symbol that is fmt()ed, which is inconvenient and error-prone. */
+/**
+ * This class mainly exists to give us an operator<< for ostreams. We could also
+ * return plain strings from SymbolTable, but then we'd have to wrap every
+ * instance of a symbol that is fmt()ed, which is inconvenient and error-prone.
+ */
class SymbolStr
{
friend class SymbolTable;
@@ -47,6 +43,11 @@ public:
friend std::ostream & operator <<(std::ostream & os, const SymbolStr & symbol);
};
+/**
+ * Symbols have the property that they can be compared efficiently
+ * (using an equality test), because the symbol table stores only one
+ * copy of each string.
+ */
class Symbol
{
friend class SymbolTable;
@@ -66,6 +67,10 @@ public:
bool operator!=(const Symbol other) const { return id != other.id; }
};
+/**
+ * Symbol table used by the parser and evaluator to represent and look
+ * up identifiers and attributes efficiently.
+ */
class SymbolTable
{
private:
@@ -74,6 +79,9 @@ private:
public:
+ /**
+ * converts a string into a symbol.
+ */
Symbol create(std::string_view s)
{
// Most symbols are looked up more than once, so we trade off insertion performance