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. v2.1.0-184-gbe7ecef


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-184-gbe7ecef
Date: Sat, 31 Aug 2013 08:44:16 +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=be7ecef05c1eea66f30360f658c610710c5cb22e

The branch, master has been updated
       via  be7ecef05c1eea66f30360f658c610710c5cb22e (commit)
      from  8ac8e2dfeb88172deab6fe453d7a2f0ad03729d6 (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 be7ecef05c1eea66f30360f658c610710c5cb22e
Author: Andy Wingo <address@hidden>
Date:   Sat Aug 31 10:44:07 2013 +0200

    unread-char: inline conversion from codepoint to bytes
    
    * libguile/ports.c (scm_ungetc_unlocked): Inline the conversion from
      codepoint to bytes for UTF-8 and latin-1 ports.  Speeds up a
      numbers-reading test case by 100% (!).

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

Summary of changes:
 libguile/ports.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/libguile/ports.c b/libguile/ports.c
index 7934379..44416cb 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -2105,15 +2105,36 @@ scm_ungetc_unlocked (scm_t_wchar c, SCM port)
 #define FUNC_NAME "scm_ungetc"
 {
   scm_t_port *pt = SCM_PTAB_ENTRY (port);
+  scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (port);
   char *result;
   char result_buf[10];
   size_t len;
 
   len = sizeof (result_buf);
-  result = u32_conv_to_encoding (pt->encoding,
-                                (enum iconv_ilseq_handler) pt->ilseq_handler,
-                                (uint32_t *) &c, 1, NULL,
-                                result_buf, &len);
+
+  if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8)
+    {
+      if (c < 0xf0)
+        {
+          result_buf[0] = (char) c;
+          result = result_buf;
+          len = 1;
+        }
+      else
+        result =
+          (char *) u32_to_u8 ((uint32_t *) &c, 1, (uint8_t *) result_buf, 
&len);
+    }
+  else if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1 && c <= 0xff)
+    {
+      result_buf[0] = (char) c;
+      result = result_buf;
+      len = 1;
+    }
+  else
+    result = u32_conv_to_encoding (pt->encoding,
+                                   (enum iconv_ilseq_handler) 
pt->ilseq_handler,
+                                   (uint32_t *) &c, 1, NULL,
+                                   result_buf, &len);
 
   if (SCM_UNLIKELY (result == NULL || len == 0))
     scm_encoding_error (FUNC_NAME, errno,


hooks/post-receive
-- 
GNU Guile



reply via email to

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