guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. release_1-9-11-152-g0


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-11-152-g0cc92ac
Date: Sun, 04 Jul 2010 16:44:45 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=0cc92ac41bdfd083bc4ce051da757cb2b00c2c02

The branch, master has been updated
       via  0cc92ac41bdfd083bc4ce051da757cb2b00c2c02 (commit)
       via  100e20c7fa1a3ae268152842a0781d9f867eda96 (commit)
      from  6069e9733163cf802e806bfa55cb4fcc54fc6ac7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0cc92ac41bdfd083bc4ce051da757cb2b00c2c02
Author: Ludovic Courtès <address@hidden>
Date:   Sun Jul 4 18:44:08 2010 +0200

    Optimize `string=' for the common case.
    
    * libguile/srfi-13.c (scm_string_eq): Add a fast path for the common
      case.

commit 100e20c7fa1a3ae268152842a0781d9f867eda96
Author: Ludovic Courtès <address@hidden>
Date:   Sun Jul 4 18:38:53 2010 +0200

    Add `scm_i_string_data'.
    
    * libguile/strings.c (STRINGBUF_CONTENTS): New macro.
      (STRINGBUF_CHARS, STRINGBUF_WIDE_CHARS): Use it.
      (scm_i_string_data): New function.
    
    * libguile/strings.h (scm_i_string_data): New declaration.

-----------------------------------------------------------------------

Summary of changes:
 libguile/srfi-13.c |   24 +++++++++++++++++++++++-
 libguile/strings.c |   24 +++++++++++++++++++++---
 libguile/strings.h |    4 +++-
 3 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/libguile/srfi-13.c b/libguile/srfi-13.c
index c4e8571..eec2961 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,28 @@ 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)))
+    {
+      /* Fast path for this common case, which avoids the repeated calls to
+        `scm_i_string_ref'.  */
+      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_data (s1),
+                                       scm_i_string_data (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);
diff --git a/libguile/strings.c b/libguile/strings.c
index d136d98..6d2b7c0 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -82,12 +82,13 @@
 #define STRINGBUF_SHARED(buf)   (SCM_CELL_WORD_0(buf) & STRINGBUF_F_SHARED)
 #define STRINGBUF_WIDE(buf)     (SCM_CELL_WORD_0(buf) & STRINGBUF_F_WIDE)
 
-#define STRINGBUF_CHARS(buf)    ((unsigned char *)                     \
+#define STRINGBUF_CONTENTS(buf) ((void *)                              \
                                  SCM_CELL_OBJECT_LOC (buf,             \
                                                      STRINGBUF_HEADER_SIZE))
-#define STRINGBUF_LENGTH(buf)   (SCM_CELL_WORD_1 (buf))
+#define STRINGBUF_CHARS(buf)    ((unsigned char *) STRINGBUF_CONTENTS (buf))
+#define STRINGBUF_WIDE_CHARS(buf) ((scm_t_wchar *) STRINGBUF_CONTENTS (buf))
 
-#define STRINGBUF_WIDE_CHARS(buf) ((scm_t_wchar *) STRINGBUF_CHARS (buf))
+#define STRINGBUF_LENGTH(buf)   (SCM_CELL_WORD_1 (buf))
 
 #define SET_STRINGBUF_SHARED(buf)                                      \
   do                                                                   \
@@ -445,6 +446,23 @@ scm_i_try_narrow_string (SCM str)
   return scm_i_is_narrow_string (str);
 }
 
+/* Return a pointer to the raw data of the string, which can be either Latin-1
+   or UCS-4 encoded data, depending on `scm_i_is_narrow_string (STR)'.  */
+const void *
+scm_i_string_data (SCM str)
+{
+  SCM buf;
+  size_t start;
+  const char *data;
+
+  get_str_buf_start (&str, &buf, &start);
+
+  data = STRINGBUF_CONTENTS (buf);
+  data += start * (scm_i_is_narrow_string (str) ? 1 : 4);
+
+  return data;
+}
+
 /* Returns a pointer to the 8-bit Latin-1 encoded character array of
    STR.  */
 const char *
diff --git a/libguile/strings.h b/libguile/strings.h
index 6eafafa..ad9518c 100644
--- a/libguile/strings.h
+++ b/libguile/strings.h
@@ -3,7 +3,7 @@
 #ifndef SCM_STRINGS_H
 #define SCM_STRINGS_H
 
-/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2004, 2005, 2006, 2008, 2009 
Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,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
@@ -172,6 +172,8 @@ SCM_INTERNAL size_t scm_i_string_length (SCM str);
 SCM_API /* FIXME: not internal */ const char *scm_i_string_chars (SCM str);
 SCM_API /* FIXME: not internal */ char *scm_i_string_writable_chars (SCM str);
 SCM_INTERNAL const scm_t_wchar *scm_i_string_wide_chars (SCM str);
+SCM_INTERNAL const void *scm_i_string_data (SCM str);
+
 SCM_INTERNAL SCM scm_i_string_start_writing (SCM str);
 SCM_INTERNAL void scm_i_string_stop_writing (void);
 SCM_INTERNAL int scm_i_is_narrow_string (SCM str);


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]