From 8d41b2b1fbe3edc870b9456b991446aaa8b3dddd Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 5 Sep 2024 10:31:35 -0400 Subject: Do the extremely obvious optimization of checking if two pieces of data are at the same location before bothering to compare them --- builtins/c_string.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'builtins/c_string.c') diff --git a/builtins/c_string.c b/builtins/c_string.c index bd35b549..47ea4858 100644 --- a/builtins/c_string.c +++ b/builtins/c_string.c @@ -21,10 +21,14 @@ public Text_t CString$as_text(const void *c_string, bool colorize, const TypeInf return Text$concat(colorize ? Text("\x1b[34mCString\x1b[m(") : Text("CString("), Text$quoted(text, colorize), Text(")")); } -public int CString$compare(const char **x, const char **y) +public int32_t CString$compare(const char **x, const char **y) { + if (x == y) + return 0; + if (!*x != !*y) return (!*y) - (!*x); + return strcmp(*x, *y); } -- cgit v1.2.3