From f33cda8d6eb1cac5b9042429e85f1096175c7ca5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 30 Aug 2023 11:26:16 -0300 Subject: New macro 'getlstr' Accesses content and length of a 'TString'. --- ldump.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'ldump.c') diff --git a/ldump.c b/ldump.c index bb15e45f..01169c12 100644 --- a/ldump.c +++ b/ldump.c @@ -112,24 +112,25 @@ static void dumpInteger (DumpState *D, lua_Integer x) { ** size==size-2 and means that string, which will be saved with ** the next available index. */ -static void dumpString (DumpState *D, TString *s) { - if (s == NULL) +static void dumpString (DumpState *D, TString *ts) { + if (ts == NULL) dumpSize(D, 0); else { - const TValue *idx = luaH_getstr(D->h, s); + const TValue *idx = luaH_getstr(D->h, ts); if (ttisinteger(idx)) { /* string already saved? */ dumpSize(D, 1); /* reuse a 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 */ - size_t size = tsslen(s); + size_t size; + const char *s = getlstr(ts, size); dumpSize(D, size + 2); - dumpVector(D, getstr(s), size); + dumpVector(D, s, size); D->nstr++; /* one more saved string */ - setsvalue(D->L, &key, s); /* the string is the key */ + 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[s] = nstr */ + luaH_finishset(D->L, D->h, &key, idx, &value); /* h[ts] = nstr */ /* integer value does not need barrier */ } } -- cgit v1.2.3-55-g6feb