From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: Optimizing ‘string=’
Date: Tue, 22 Jun 2010 22:43:55 +0200 [thread overview]
Message-ID: <87d3viiyr8.fsf@gnu.org> (raw)
In-Reply-To: <87k4pqj1pc.fsf@gnu.org> ("Ludovic Courtès"'s message of "Tue, 22 Jun 2010 21:40:15 +0200")
[-- Attachment #1: Type: text/plain, Size: 122 bytes --]
Oops, there was a thinko in the patch, whereby wide strings would not be
entirely compared. Here’s an updated one:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1316 bytes --]
diff --git a/libguile/srfi-13.c b/libguile/srfi-13.c
index c4e8571..f29ceaa 100644
--- a/libguile/srfi-13.c
+++ b/libguile/srfi-13.c
@@ -1,6 +1,6 @@
/* srfi-13.c --- SRFI-13 procedures for Guile
*
- * Copyright (C) 2001, 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2004, 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -1168,6 +1168,26 @@ SCM_DEFINE (scm_string_eq, "string=", 2, 4, 0,
"value otherwise.")
#define FUNC_NAME s_scm_string_eq
{
+ if (SCM_LIKELY (scm_i_is_narrow_string (s1) == scm_i_is_narrow_string (s2)
+ && SCM_UNBNDP (start1) && SCM_UNBNDP (end1)
+ && SCM_UNBNDP (start2) && SCM_UNBNDP (end2)))
+ {
+ size_t len1, len2;
+
+ len1 = scm_i_string_length (s1);
+ len2 = scm_i_string_length (s2);
+
+ if (SCM_LIKELY (len1 == len2))
+ {
+ if (!scm_i_is_narrow_string (s1))
+ len1 *= 4;
+
+ return scm_from_bool (memcmp (scm_i_string_chars (s1),
+ scm_i_string_chars (s2),
+ len1) == 0);
+ }
+ }
+
return compare_strings (FUNC_NAME, 0,
s1, s2, start1, end1, start2, end2,
SCM_BOOL_F, SCM_BOOL_F, SCM_BOOL_F, SCM_BOOL_F, SCM_BOOL_T);
[-- Attachment #3: Type: text/plain, Size: 12 bytes --]
Ludo’.
next prev parent reply other threads:[~2010-06-22 20:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-22 19:40 Optimizing ‘string=’ Ludovic Courtès
2010-06-22 20:43 ` Ludovic Courtès [this message]
2010-06-23 2:25 ` Mike Gran
2010-06-22 20:51 ` Andy Wingo
2010-06-22 21:32 ` Ludovic Courtès
2010-06-22 21:54 ` Andy Wingo
2010-07-02 13:32 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d3viiyr8.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).