about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/symbol-table.cc
blob: 2b27ca54c289baeb2986cbed87548561c2027ba4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "libexpr/symbol-table.hh"

#include <absl/container/node_hash_set.h>
#include <absl/strings/string_view.h>

namespace nix {

Symbol SymbolTable::Create(absl::string_view sym) {
  auto it = symbols_.emplace(sym);
  const std::string* ptr = &(*it.first);
  return Symbol(ptr);
}

size_t SymbolTable::Size() const { return symbols_.size(); }

size_t SymbolTable::TotalSize() const {
  size_t n = 0;
  for (auto& i : symbols_) {
    n += i.size();
  }
  return n;
}

}  // namespace nix