]> code.delx.au - gnu-emacs/commitdiff
(string_char_to_byte): Optimize for ASCII only string.
authorKenichi Handa <handa@m17n.org>
Thu, 29 Jan 2004 02:54:22 +0000 (02:54 +0000)
committerKenichi Handa <handa@m17n.org>
Thu, 29 Jan 2004 02:54:22 +0000 (02:54 +0000)
(string_byte_to_char): Likewise.

src/ChangeLog
src/fns.c

index 100cfd83f06645d2aeec004c50db6ce3b78257a3..9d52344d5b3fa361924f2305fc0a75505ff989db 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-29  Kenichi Handa  <handa@m17n.org>
+
+       * fns.c (string_char_to_byte): Optimize for ASCII only string.
+       (string_byte_to_char): Likewise.
+
 2004-01-28  Peter Runestig  <peter@runestig.com>
 
        * makefile.w32-in, w32fns.c: Add `default-printer-name' function.
index 6383e09302b0701af3b87e4ad5ca57164fa6733a..493d7ba289706f0226f88585791234f3d0ebb95d 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -884,12 +884,11 @@ string_char_to_byte (string, char_index)
   int best_below, best_below_byte;
   int best_above, best_above_byte;
 
-  if (! STRING_MULTIBYTE (string))
-    return char_index;
-
   best_below = best_below_byte = 0;
   best_above = SCHARS (string);
   best_above_byte = SBYTES (string);
+  if (best_above == best_above_byte)
+    return char_index;
 
   if (EQ (string, string_char_byte_cache_string))
     {
@@ -957,12 +956,11 @@ string_byte_to_char (string, byte_index)
   int best_below, best_below_byte;
   int best_above, best_above_byte;
 
-  if (! STRING_MULTIBYTE (string))
-    return byte_index;
-
   best_below = best_below_byte = 0;
   best_above = SCHARS (string);
   best_above_byte = SBYTES (string);
+  if (best_above == best_above_byte)
+    return byte_index;
 
   if (EQ (string, string_char_byte_cache_string))
     {