| 9202 | |
| 9203 | |
| 9204 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { |
| 9205 | GCObject *o; |
| 9206 | unsigned int h = cast(unsigned int, l); /* seed */ |
| 9207 | size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ |
| 9208 | size_t l1; |
| 9209 | for (l1=l; l1>=step; l1-=step) /* compute hash */ |
| 9210 | h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); |
| 9211 | for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; |
| 9212 | o != NULL; |
| 9213 | o = o->gch.next) { |
| 9214 | TString *ts = rawgco2ts(o); |
| 9215 | if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { |
| 9216 | /* string may be dead */ |
| 9217 | if (isdead(G(L), o)) changewhite(o); |
| 9218 | return ts; |
| 9219 | } |
| 9220 | } |
| 9221 | return newlstr(L, str, l, h); /* not found */ |
| 9222 | } |
| 9223 | |
| 9224 | |
| 9225 | Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { |
no test coverage detected