summaryrefslogtreecommitdiffstats
path: root/generic/tclInt.h
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-11-12 02:25:05 (GMT)
committerhobbs <hobbs>2002-11-12 02:25:05 (GMT)
commitf9bba24db92a24f0b4fdc292d6a9d260058aac82 (patch)
treedd25dc093de7015ac1b0a644cdb8ceb4651cb482 /generic/tclInt.h
parent64c00226c42e6f2f2b5d6bd03cbd9de5b6cc96a6 (diff)
downloadtcl-f9bba24db92a24f0b4fdc292d6a9d260058aac82.zip
tcl-f9bba24db92a24f0b4fdc292d6a9d260058aac82.tar.gz
tcl-f9bba24db92a24f0b4fdc292d6a9d260058aac82.tar.bz2
* generic/tclInt.h: add macro version of Tcl_UtfToUniChar
(TclUtfToUniChar) that does the one-byte utf-char check without calling Tcl_UtfToUniChar, for use by the core. This brings notable speedups for primarily ascii string handling.
Diffstat (limited to 'generic/tclInt.h')
-rw-r--r--generic/tclInt.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index e5e6408..c7ffc1d 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInt.h,v 1.112 2002/10/23 09:55:14 dkf Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.113 2002/11/12 02:25:05 hobbs Exp $
*/
#ifndef _TCLINT
@@ -2229,6 +2229,25 @@ extern Tcl_Mutex tclObjMutex;
/*
*----------------------------------------------------------------
+ * Macro used by the Tcl core get a unicode char from a utf string.
+ * It checks to see if we have a one-byte utf char before calling
+ * the real Tcl_UtfToUniChar, as this will save a lot of time for
+ * primarily ascii string handling. The macro's expression result
+ * is 1 for the 1-byte case or the result of Tcl_UtfToUniChar.
+ * The ANSI C "prototype" for this macro is:
+ *
+ * EXTERN int TclUtfToUniChar _ANSI_ARGS_((CONST char *string,
+ * Tcl_UniChar *ch));
+ *----------------------------------------------------------------
+ */
+
+#define TclUtfToUniChar(str, chPtr) \
+ ((((unsigned char) *(str)) < 0xC0) ? \
+ ((*(chPtr) = (Tcl_UniChar) *(str)), 1) \
+ : Tcl_UtfToUniChar(str, chPtr))
+
+/*
+ *----------------------------------------------------------------
* Macro used by the Tcl core to compare Unicode strings. On
* big-endian systems we can use the more efficient memcmp, but
* this would not be lexically correct on little-endian systems.