From 34980e46f1c6693dba7bcab875f6a227085a87ec Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 10 Feb 2009 14:38:55 +0000 Subject: * generic/tclStringObj.c (Tcl_GetUnicode*): Reduce code duplication. --- ChangeLog | 4 ++++ generic/tclStringObj.c | 27 ++------------------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 187317d..4a15b01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-02-10 Don Porter + + * generic/tclStringObj.c (Tcl_GetUnicode*): Reduce code duplication. + 2009-02-09 Jan Nijtmans * generic/tclCompile.c: fix [Bug 2555129] const compiler warning (as diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 589d046..da17c2f 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -33,7 +33,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclStringObj.c,v 1.87 2009/02/05 21:27:45 dkf Exp $ */ + * RCS: @(#) $Id: tclStringObj.c,v 1.88 2009/02/10 14:38:55 dgp Exp $ */ #include "tclInt.h" #include "tommath.h" @@ -544,30 +544,7 @@ Tcl_GetUnicode( Tcl_Obj *objPtr) /* The object to find the unicode string * for. */ { - String *stringPtr; - - SetStringFromAny(NULL, objPtr); - stringPtr = GET_STRING(objPtr); - - if ((stringPtr->numChars == -1) || (stringPtr->hasUnicode == 0)) { - /* - * We haven't yet calculated the length, or all of the characters in - * the Utf string are 1 byte chars (so we didn't store the unicode - * str). Since this function must return a unicode string, and one has - * not yet been stored, force the Unicode to be calculated and stored - * now. - */ - - FillUnicodeRep(objPtr); - - /* - * We need to fetch the pointer again because we have just reallocated - * the structure to make room for the Unicode data. - */ - - stringPtr = GET_STRING(objPtr); - } - return stringPtr->unicode; + return Tcl_GetUnicodeFromObj(objPtr, NULL); } /* -- cgit v0.12