about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-08T13·19+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-08T13·36+0200
commit9deb822180fb80638559fe3c45c6a77a2b56ff40 (patch)
treeaa11694219d4ce88f028de4c8acd18cbd4f8b975 /src/libexpr/nixexpr.hh
parentb1e3b1a4ac8c276f503713f6002c3b42efef2ae8 (diff)
Deduplicate filenames in Pos
This saves ~4 MiB of RAM for NixOS system instantiation, and ~18 MiB
for "nix-env -qa".
Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r--src/libexpr/nixexpr.hh8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index f5cc69801e42..2178c016ec11 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -23,14 +23,16 @@ MakeError(UndefinedVarError, Error)
 
 struct Pos
 {
-    string file;
+    Symbol file;
     unsigned int line, column;
     Pos() : line(0), column(0) { };
-    Pos(const string & file, unsigned int line, unsigned int column)
+    Pos(const Symbol & file, unsigned int line, unsigned int column)
         : file(file), line(line), column(column) { };
     bool operator < (const Pos & p2) const
     {
-        int d = file.compare(p2.file);
+        if (!line) return p2.line;
+        if (!p2.line) return false;
+        int d = ((string) file).compare((string) p2.file);
         if (d < 0) return true;
         if (d > 0) return false;
         if (line < p2.line) return true;