libexpr: Optimize prim_attrNames a bit
Instead of having lexicographicOrder() create a temporary sorted array of Attr*:s and copying attr names from that, copy the attr names first and then sort that.
This commit is contained in:
parent
f67a7007a2
commit
b8bed7da14
|
@ -1138,8 +1138,11 @@ static void prim_attrNames(EvalState & state, const Pos & pos, Value * * args, V
|
||||||
state.mkList(v, args[0]->attrs->size());
|
state.mkList(v, args[0]->attrs->size());
|
||||||
|
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
for (auto & i : args[0]->attrs->lexicographicOrder())
|
for (auto & i : *args[0]->attrs)
|
||||||
mkString(*(v.listElems()[n++] = state.allocValue()), i->name);
|
mkString(*(v.listElems()[n++] = state.allocValue()), i.name);
|
||||||
|
|
||||||
|
std::sort(v.listElems(), v.listElems() + n,
|
||||||
|
[](Value * v1, Value * v2) { return strcmp(v1->string.s, v2->string.s) < 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue