mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 23:42:43 +01:00
Use Value::misc to store strings
This allows strings < 23 characters (up from 16) to be stored directly in Value. On a NixOS 19.03 system configuration evaluation, this allows 1060588 out of 1189295 (89%) strings to be stored in Value.
This commit is contained in:
parent
742a8046de
commit
a38a7b495c
4 changed files with 25 additions and 12 deletions
|
|
@ -497,10 +497,9 @@ LocalNoInline(void addErrorPrefix(Error & e, const char * s, const string & s2,
|
|||
void mkString(Value & v, const char * s)
|
||||
{
|
||||
auto len = strlen(s); // FIXME: only need to know if > short
|
||||
if (len < WORD_SIZE * 2) {
|
||||
strcpy((char *) &v.string, s);
|
||||
v.type = tShortString;
|
||||
} else
|
||||
if (len < WORD_SIZE * 2 + Object::miscBytes)
|
||||
v.setShortString(s);
|
||||
else
|
||||
mkStringNoCopy(v, dupString(s));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue