From f9bba24db92a24f0b4fdc292d6a9d260058aac82 Mon Sep 17 00:00:00 2001 From: hobbs Date: Tue, 12 Nov 2002 02:25:05 +0000 Subject: * 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. --- generic/tclInt.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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. -- cgit v0.12