Browse Source

Solving merge issue with use of tables in dump/undump

The use of tables in dump/undump to reuse strings did not exist in
the version that changed the representation of arrays, so it was not
corrected for the new API for tables.
pull/33/head
Roberto Ierusalimschy 1 year ago
parent
commit
19afd91687
  1. 8
      ldump.c
  2. 5
      lundump.c

8
ldump.c

@ -116,10 +116,10 @@ static void dumpString (DumpState *D, TString *ts) {
if (ts == NULL)
dumpSize(D, 0);
else {
const TValue *idx = luaH_getstr(D->h, ts);
if (ttisinteger(idx)) { /* string already saved? */
TValue idx;
if (luaH_getstr(D->h, ts, &idx) == HOK) { /* string already saved? */
dumpSize(D, 1); /* reuse a saved string */
dumpInt(D, ivalue(idx)); /* index of saved string */
dumpInt(D, ivalue(&idx)); /* index of saved string */
}
else { /* must write and save the string */
TValue key, value; /* to save the string in the hash */
@ -130,7 +130,7 @@ static void dumpString (DumpState *D, TString *ts) {
D->nstr++; /* one more saved string */
setsvalue(D->L, &key, ts); /* the string is the key */
setivalue(&value, D->nstr); /* its index is the value */
luaH_finishset(D->L, D->h, &key, idx, &value); /* h[ts] = nstr */
luaH_set(D->L, D->h, &key, &value); /* h[ts] = nstr */
/* integer value does not need barrier */
}
}

5
lundump.c

@ -143,8 +143,9 @@ static TString *loadStringN (LoadState *S, Proto *p) {
return NULL;
else if (size == 1) { /* previously saved string? */
int idx = loadInt(S); /* get its index */
const TValue *stv = luaH_getint(S->h, idx);
return tsvalue(stv);
TValue stv;
luaH_getint(S->h, idx, &stv);
return tsvalue(&stv);
}
else if (size -= 2, size <= LUAI_MAXSHORTLEN) { /* short string? */
char buff[LUAI_MAXSHORTLEN];

Loading…
Cancel
Save