[ooo-build-commit] patches/dev300
Kohei Yoshida
kohei at kemper.freedesktop.org
Thu Dec 10 10:22:49 PST 2009
patches/dev300/sal-strintern-speed-char-upper.diff | 56 +++++++++++++++++----
1 file changed, 47 insertions(+), 9 deletions(-)
New commits:
commit f899e8e8771bd9630e4bb7f7293899455754182c
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Thu Dec 10 13:17:50 2009 -0500
Slightly tweaked the string intern code to make it more generic.
* patches/dev300/sal-strintern-speed-char-upper.diff: for now
I'm not using bits in the text encoding value itself. I'll
punt that for later.
diff --git a/patches/dev300/sal-strintern-speed-char-upper.diff b/patches/dev300/sal-strintern-speed-char-upper.diff
index ca91867..ab5c0e5 100644
--- a/patches/dev300/sal-strintern-speed-char-upper.diff
+++ b/patches/dev300/sal-strintern-speed-char-upper.diff
@@ -1,30 +1,68 @@
diff --git sal/rtl/source/ustring.c sal/rtl/source/ustring.c
-index b545ff4..95277fe 100644
+index b545ff4..9b9145e 100644
--- sal/rtl/source/ustring.c
+++ sal/rtl/source/ustring.c
-@@ -835,6 +835,28 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr,
+@@ -799,6 +799,29 @@ void SAL_CALL rtl_uString_intern( rtl_uString ** newStr,
+ }
+ }
+
++static int rtl_canGuessUOutputLength( int len, rtl_TextEncoding eTextEncoding )
++{
++ // FIXME: Maybe we should use a bit flag in the higher bits of the
++ // eTextEncoding value itself to determine the encoding type. But if we
++ // do, be sure to mask the value in certain places that expect the values
++ // to be numbered serially from 0 and up. One such place is
++ // Impl_getTextEncodingData().
++
++ switch ( eTextEncoding )
++ {
++ // 1 to 1 (with no zero elements)
++ case RTL_TEXTENCODING_IBM_437:
++ case RTL_TEXTENCODING_IBM_850:
++ case RTL_TEXTENCODING_IBM_860:
++ case RTL_TEXTENCODING_IBM_861:
++ case RTL_TEXTENCODING_IBM_863:
++ case RTL_TEXTENCODING_IBM_865:
++ return len;
++ break;
++ }
++ return 0;
++}
++
+ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr,
+ const sal_Char * str,
+ sal_Int32 len,
+@@ -816,6 +839,7 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr,
+
+ if ( len < 256 )
+ { // try various optimisations
++ sal_Int32 ulen;
+ if ( len < 0 )
+ len = strlen( str );
+ if ( eTextEncoding == RTL_TEXTENCODING_ASCII_US )
+@@ -835,6 +859,28 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr,
rtl_ustring_intern_internal( newStr, pScratch, CANNOT_RETURN );
return;
}
-+ else if ( eTextEncoding == RTL_TEXTENCODING_IBM_850 )
++ else if ( (ulen = rtl_canGuessUOutputLength(len, eTextEncoding)) != 0 )
+ {
+ rtl_uString *pScratch;
+ rtl_TextToUnicodeConverter hConverter;
+ sal_Size nDestChars, nSrcBytes;
+ sal_uInt32 nInfo;
+
-+ hConverter = rtl_createTextToUnicodeConverter( eTextEncoding );
-+ pScratch = alloca( sizeof(rtl_uString) + len * sizeof (IMPL_RTL_STRCODE) );
++ pScratch = alloca( sizeof(rtl_uString) + ulen * sizeof (IMPL_RTL_STRCODE) );
+
++ hConverter = rtl_createTextToUnicodeConverter( eTextEncoding );
+ nDestChars = rtl_convertTextToUnicode(
-+ hConverter, 0, str, len, pScratch->buffer, len, convertFlags, &nInfo, &nSrcBytes );
-+ pScratch->length = len;
++ hConverter, 0, str, len, pScratch->buffer, ulen, convertFlags, &nInfo, &nSrcBytes );
++ rtl_destroyTextToUnicodeConverter( hConverter );
+
+ if (pInfo)
+ *pInfo = nInfo;
+
++ pScratch->length = ulen;
+ rtl_ustring_intern_internal( newStr, pScratch, CANNOT_RETURN );
-+ rtl_destroyTextToUnicodeConverter( hConverter );
+ return;
+ }
+
@@ -32,7 +70,7 @@ index b545ff4..95277fe 100644
}
diff --git sal/textenc/tcvtbyte.c sal/textenc/tcvtbyte.c
-index be39b8e..c21f69a 100644
+index be39b8e..3cf9ef3 100644
--- sal/textenc/tcvtbyte.c
+++ sal/textenc/tcvtbyte.c
@@ -643,6 +643,51 @@ sal_Size ImplCharToUnicode( const ImplTextConverterData* pData,
More information about the ooo-build-commit
mailing list