Unnecessary constructor for each UT_UCS_strcpy_char


Subject: Unnecessary constructor for each UT_UCS_strcpy_char
From: Matti Picus (matti@picus.org)
Date: Sat Sep 22 2001 - 14:45:47 CDT


UT_UCS_strcpy_char instantiates a UT_Mbtowc class instance on each
call. As the default constructor uses values that should remain constant
throughout the lifetime of the application, creating and destroying the
UT_Mbtowc instance is unnecessary. Especially in a function as frequently
used as UT_USC_strcpy_char. Here is a patch to make the variable static
(created only once). Could someone review this and (hopefully) check it in?
Thanks,
Matti

Index: abi/src/af/util/xp/ut_string.cpp
===================================================================
RCS file: /cvsroot/abi/src/af/util/xp/ut_string.cpp,v
retrieving revision 1.66
diff -c -r1.66 ut_string.cpp
*** abi/src/af/util/xp/ut_string.cpp 2001/08/10 18:32:38 1.66
--- abi/src/af/util/xp/ut_string.cpp 2001/09/22 18:30:32
***************
*** 692,698 ****
           unsigned char * s = (unsigned char *) src;

   #ifndef WITHOUT_MB
! UT_Mbtowc m;
           wchar_t wc;
   #endif

--- 692,698 ----
           unsigned char * s = (unsigned char *) src;

   #ifndef WITHOUT_MB
! static UT_Mbtowc m;
           wchar_t wc;
   #endif



This archive was generated by hypermail 2b25 : Sat Sep 22 2001 - 13:46:26 CDT