w6l: replace streq/streqd clones with strings.compare (Wave-2 hand-rolled->lib)
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
|
||||
package w6l;
|
||||
|
||||
import strings;
|
||||
|
||||
type lsym = struct {
|
||||
name: str,
|
||||
val: u64, // offset within combined .text (or .data when
|
||||
@@ -77,20 +79,10 @@ type lnk = struct {
|
||||
dynn: i32, // number of syms routed through PLT
|
||||
};
|
||||
|
||||
fn streq(a: str, b: str) bool = {
|
||||
if (a.len != b.len) { return false; };
|
||||
let i: i32 = 0;
|
||||
for (i < a.len) {
|
||||
if (a[i] != b[i]) { return false; };
|
||||
i += 1;
|
||||
};
|
||||
return true;
|
||||
};
|
||||
|
||||
export fn intern(l: *lnk, name: str) *lsym = {
|
||||
let s: *lsym = l.syms;
|
||||
for (s != nil) {
|
||||
if (streq(s.name, name)) { return s; };
|
||||
if (strings.compare(s.name, name) == 0) { return s; };
|
||||
s = s.snext;
|
||||
};
|
||||
let n: *lsym = alloc(lsym { name = name, snext = l.syms })!;
|
||||
@@ -101,7 +93,7 @@ export fn intern(l: *lnk, name: str) *lsym = {
|
||||
export fn lookup(l: *lnk, name: str) *lsym = {
|
||||
let s: *lsym = l.syms;
|
||||
for (s != nil) {
|
||||
if (streq(s.name, name)) { return s; };
|
||||
if (strings.compare(s.name, name) == 0) { return s; };
|
||||
s = s.snext;
|
||||
};
|
||||
return nil;
|
||||
|
||||
Reference in New Issue
Block a user