~ecs/public-inbox

[PATCH qbe2c 1/2] Use binary search for keyword detection

Details
Message ID
<20221222194632.12063-1-sebastian@sebsite.pw>
Sender timestamp
1671720391
DKIM signature
missing
Download raw message
Patch: +1 -5
Signed-off-by: Sebastian <sebastian@sebsite.pw>
---
 unparse.ha | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/unparse.ha b/unparse.ha
index 95fb32f..fcba5b1 100644
--- a/unparse.ha
+++ b/unparse.ha
@@ -68,11 +68,7 @@ const keywords: [_]str = [
	"while",
];

fn iskeyword(n: str) bool = {
	let i = 0z;
	for (i < len(keywords) && strings::compare(keywords[i], n) < 0) i += 1;
	return i < len(keywords) && keywords[i] == n;
};
fn iskeyword(n: str) bool = sort::searchstrings(keywords, n) is size;

fn name(c: *ctx, n: (str | qbe::temp | datatype)) (void | io::error) = {
	if (!(n is qbe::temp || n is datatype || strings::contains(n: str, '.', '$') ||
-- 
2.38.1
Reply to thread Export thread (mbox)