guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

212/376: attrNames: Don't allocate duplicates of the symbols


From: Ludovic Courtès
Subject: 212/376: attrNames: Don't allocate duplicates of the symbols
Date: Wed, 28 Jan 2015 22:05:07 +0000

civodul pushed a commit to tag 1.8
in repository guix.

commit 2d6cd8aafdc40194497af4ed924a890f6d0a92aa
Author: Eelco Dolstra <address@hidden>
Date:   Fri Sep 19 18:11:46 2014 +0200

    attrNames: Don't allocate duplicates of the symbols
---
 src/libexpr/primops.cc |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index a5bac3f..66321c7 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -914,13 +914,11 @@ static void prim_attrNames(EvalState & state, const Pos & 
pos, Value * * args, V
 
     state.mkList(v, args[0]->attrs->size());
 
-    StringSet names;
-    foreach (Bindings::iterator, i, *args[0]->attrs)
-        names.insert(i->name);
-
     unsigned int n = 0;
-    foreach (StringSet::iterator, i, names)
-        mkString(*(v.list.elems[n++] = state.allocValue()), *i);
+    for (auto & i : *args[0]->attrs)
+        mkString(*(v.list.elems[n++] = state.allocValue()), i.name);
+
+    std::sort(v.list.elems, v.list.elems + n, [](Value * v1, Value * v2) { 
return strcmp(v1->string.s, v2->string.s) < 0; });
 }
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]