wcc/cgen: localfind inline name-loop -> strings.compare (Wave-2 hand-rolled->lib)

The open-coded len-guard + byte-by-byte equality loop in localfind is
exactly strings.compare(ln, name) == 0 (==0 demands equal length AND
equal bytes; no prefix false-match). Matches cstage cgen.c:1669
strcmp(l->name, name) == 0. The @-fallback streq + localfindnode streq
calls are shared-helper calls, left for the wholesale swap (#17).

Regenerated w6c + wwdump combined.ww (the only amalgamations embedding
cgen.ww's localfind).
This commit is contained in:
2026-06-03 04:19:38 +09:00
parent b4b28bbf02
commit a67259ca69
3 changed files with 6 additions and 27 deletions

View File

@@ -30,6 +30,7 @@ import tok;
import typ;
import sym;
import strconv;
import strings;
import io;
import memio;
// Split files. Bundler pulls these in transitively so consumers only
@@ -672,15 +673,7 @@ fn localfind(c: *cgen, name: str) i32 = {
let l: *local = c.locals;
for (l != nil) {
let ln: str = l.name;
if (ln.len == name.len) {
let i: i32 = 0;
let eq: bool = true;
for (i < name.len) {
if (ln[i] != name[i]) { eq = false; i = name.len; }
else { i += 1; };
};
if (eq) { return l.off; };
};
if (strings.compare(ln, name) == 0) { return l.off; };
l = l.lnext;
};
if (name.len > 0) {