From 6cb69b170f40e4a46ddd16307f6625c7ba78dc4b Mon Sep 17 00:00:00 2001 From: "jaggernaut%netscape.com" Date: Sun, 23 Dec 2001 02:56:41 +0000 Subject: [PATCH] Bug 115671: Add faster To{Upper,Lower}Case for nsASingleFragment{C}String, r=dbaron, sr=dveditz, and ns{C}String, r=bbaetz, sr=scc --- intl/unicharutil/util/nsUnicharUtils.cpp | 31 ++++++++++++++++++++++ intl/unicharutil/util/nsUnicharUtils.h | 16 +++++++++--- string/obsolete/nsString.h | 2 ++ string/obsolete/nsString2.h | 2 ++ string/public/nsReadableUtils.h | 10 +++++++ string/src/nsReadableUtils.cpp | 33 ++++++++++++++++++++++++ xpcom/string/obsolete/nsString.h | 2 ++ xpcom/string/obsolete/nsString2.h | 2 ++ xpcom/string/public/nsReadableUtils.h | 10 +++++++ xpcom/string/src/nsReadableUtils.cpp | 33 ++++++++++++++++++++++++ 10 files changed, 137 insertions(+), 4 deletions(-) diff --git a/intl/unicharutil/util/nsUnicharUtils.cpp b/intl/unicharutil/util/nsUnicharUtils.cpp index 10fe8829ffed..8804f6a5ca1c 100644 --- a/intl/unicharutil/util/nsUnicharUtils.cpp +++ b/intl/unicharutil/util/nsUnicharUtils.cpp @@ -20,6 +20,7 @@ * Contributor(s): * Alec Flett */ +#include "nsString.h" #include "nsUnicharUtils.h" #include "nsReadableUtils.h" #include "nsUnicharUtilCIID.h" @@ -98,6 +99,21 @@ ToLowerCase( nsAString& aString ) copy_string(aString.BeginWriting(fromBegin), aString.EndWriting(fromEnd), converter); } +void +ToLowerCase( nsASingleFragmentString& aString ) + { + ConvertToLowerCase converter; + PRUnichar* start; + converter.write(aString.BeginWriting(start), aString.Length()); + } + +void +ToLowerCase( nsString& aString ) + { + ConvertToLowerCase converter; + converter.write(aString.mUStr, aString.mLength); + } + class CopyToLowerCase { public: @@ -157,6 +173,21 @@ ToUpperCase( nsAString& aString ) copy_string(aString.BeginWriting(fromBegin), aString.EndWriting(fromEnd), converter); } +void +ToUpperCase( nsASingleFragmentString& aString ) + { + ConvertToUpperCase converter; + PRUnichar* start; + converter.write(aString.BeginWriting(start), aString.Length()); + } + +void +ToUpperCase( nsString& aString ) + { + ConvertToUpperCase converter; + converter.write(aString.mUStr, aString.mLength); + } + class CopyToUpperCase { public: diff --git a/intl/unicharutil/util/nsUnicharUtils.h b/intl/unicharutil/util/nsUnicharUtils.h index 41a24b5273c1..c72a9230ada8 100644 --- a/intl/unicharutil/util/nsUnicharUtils.h +++ b/intl/unicharutil/util/nsUnicharUtils.h @@ -20,12 +20,22 @@ * Contributor(s): */ +#ifndef nsAString_h___ #include "nsAString.h" +#endif + +class nsASingleFragmentString; +class nsString; -// to be turned on as a part of bug 100214 -//#if 0 void ToLowerCase( nsAString& ); void ToUpperCase( nsAString& ); + +void ToLowerCase( nsASingleFragmentString& ); +void ToUpperCase( nsASingleFragmentString& ); + +void ToLowerCase( nsString& ); +void ToUpperCase( nsString& ); + void ToLowerCase( const nsAString& aSource, nsAString& aDest ); void ToUpperCase( const nsAString& aSource, nsAString& aDest ); @@ -40,8 +50,6 @@ class nsCaseInsensitiveStringComparator }; -//#endif - PRUnichar ToUpperCase(PRUnichar); PRUnichar ToLowerCase(PRUnichar); diff --git a/string/obsolete/nsString.h b/string/obsolete/nsString.h index 3c132761534b..6b062626f2ba 100644 --- a/string/obsolete/nsString.h +++ b/string/obsolete/nsString.h @@ -85,6 +85,8 @@ class NS_COM nsCString : public: friend class nsString; + friend NS_COM void ToUpperCase( nsCString& ); + friend NS_COM void ToLowerCase( nsCString& ); protected: virtual const nsBufferHandle* GetFlatBufferHandle() const; diff --git a/string/obsolete/nsString2.h b/string/obsolete/nsString2.h index 576187ab2862..60bc3b12a347 100644 --- a/string/obsolete/nsString2.h +++ b/string/obsolete/nsString2.h @@ -98,6 +98,8 @@ class NS_COM nsString : public: friend class nsCString; friend class nsLinebreakConverter; + friend void ToLowerCase( nsString& ); + friend void ToUpperCase( nsString& ); protected: virtual const nsBufferHandle* GetFlatBufferHandle() const; diff --git a/string/public/nsReadableUtils.h b/string/public/nsReadableUtils.h index 2188ea2db804..427caeb4356e 100755 --- a/string/public/nsReadableUtils.h +++ b/string/public/nsReadableUtils.h @@ -39,6 +39,8 @@ #include "nsAStringGenerator.h" #endif +class nsASingleFragmentCString; +class nsCString; NS_COM size_t Distance( const nsAString::const_iterator&, const nsAString::const_iterator& ); NS_COM size_t Distance( const nsACString::const_iterator&, const nsACString::const_iterator& ); @@ -174,6 +176,14 @@ NS_COM void ToUpperCase( nsACString& ); NS_COM void ToLowerCase( nsACString& ); +NS_COM void ToUpperCase( nsASingleFragmentCString& ); + +NS_COM void ToLowerCase( nsASingleFragmentCString& ); + +NS_COM void ToUpperCase( nsCString& ); + +NS_COM void ToLowerCase( nsCString& ); + /** * Converts case from string aSource to aDest. */ diff --git a/string/src/nsReadableUtils.cpp b/string/src/nsReadableUtils.cpp index 6b316e73e59f..e12b82e1a6d7 100755 --- a/string/src/nsReadableUtils.cpp +++ b/string/src/nsReadableUtils.cpp @@ -371,6 +371,22 @@ ToUpperCase( nsACString& aCString ) copy_string(aCString.BeginWriting(fromBegin), aCString.EndWriting(fromEnd), converter); } +NS_COM +void +ToUpperCase( nsASingleFragmentCString& aCString ) + { + ConvertToUpperCase converter; + char* start; + converter.write(aCString.BeginWriting(start), aCString.Length()); + } + +NS_COM +void +ToUpperCase( nsCString& aCString ) + { + ConvertToUpperCase converter; + converter.write(aCString.mStr, aCString.mLength); + } /** * A character sink for copying with case conversion. @@ -449,6 +465,23 @@ ToLowerCase( nsACString& aCString ) copy_string(aCString.BeginWriting(fromBegin), aCString.EndWriting(fromEnd), converter); } +NS_COM +void +ToLowerCase( nsASingleFragmentCString& aCString ) + { + ConvertToLowerCase converter; + char* start; + converter.write(aCString.BeginWriting(start), aCString.Length()); + } + +NS_COM +void +ToLowerCase( nsCString& aCString ) + { + ConvertToLowerCase converter; + converter.write(aCString.mStr, aCString.mLength); + } + /** * A character sink for copying with case conversion. */ diff --git a/xpcom/string/obsolete/nsString.h b/xpcom/string/obsolete/nsString.h index 3c132761534b..6b062626f2ba 100644 --- a/xpcom/string/obsolete/nsString.h +++ b/xpcom/string/obsolete/nsString.h @@ -85,6 +85,8 @@ class NS_COM nsCString : public: friend class nsString; + friend NS_COM void ToUpperCase( nsCString& ); + friend NS_COM void ToLowerCase( nsCString& ); protected: virtual const nsBufferHandle* GetFlatBufferHandle() const; diff --git a/xpcom/string/obsolete/nsString2.h b/xpcom/string/obsolete/nsString2.h index 576187ab2862..60bc3b12a347 100644 --- a/xpcom/string/obsolete/nsString2.h +++ b/xpcom/string/obsolete/nsString2.h @@ -98,6 +98,8 @@ class NS_COM nsString : public: friend class nsCString; friend class nsLinebreakConverter; + friend void ToLowerCase( nsString& ); + friend void ToUpperCase( nsString& ); protected: virtual const nsBufferHandle* GetFlatBufferHandle() const; diff --git a/xpcom/string/public/nsReadableUtils.h b/xpcom/string/public/nsReadableUtils.h index 2188ea2db804..427caeb4356e 100755 --- a/xpcom/string/public/nsReadableUtils.h +++ b/xpcom/string/public/nsReadableUtils.h @@ -39,6 +39,8 @@ #include "nsAStringGenerator.h" #endif +class nsASingleFragmentCString; +class nsCString; NS_COM size_t Distance( const nsAString::const_iterator&, const nsAString::const_iterator& ); NS_COM size_t Distance( const nsACString::const_iterator&, const nsACString::const_iterator& ); @@ -174,6 +176,14 @@ NS_COM void ToUpperCase( nsACString& ); NS_COM void ToLowerCase( nsACString& ); +NS_COM void ToUpperCase( nsASingleFragmentCString& ); + +NS_COM void ToLowerCase( nsASingleFragmentCString& ); + +NS_COM void ToUpperCase( nsCString& ); + +NS_COM void ToLowerCase( nsCString& ); + /** * Converts case from string aSource to aDest. */ diff --git a/xpcom/string/src/nsReadableUtils.cpp b/xpcom/string/src/nsReadableUtils.cpp index 6b316e73e59f..e12b82e1a6d7 100755 --- a/xpcom/string/src/nsReadableUtils.cpp +++ b/xpcom/string/src/nsReadableUtils.cpp @@ -371,6 +371,22 @@ ToUpperCase( nsACString& aCString ) copy_string(aCString.BeginWriting(fromBegin), aCString.EndWriting(fromEnd), converter); } +NS_COM +void +ToUpperCase( nsASingleFragmentCString& aCString ) + { + ConvertToUpperCase converter; + char* start; + converter.write(aCString.BeginWriting(start), aCString.Length()); + } + +NS_COM +void +ToUpperCase( nsCString& aCString ) + { + ConvertToUpperCase converter; + converter.write(aCString.mStr, aCString.mLength); + } /** * A character sink for copying with case conversion. @@ -449,6 +465,23 @@ ToLowerCase( nsACString& aCString ) copy_string(aCString.BeginWriting(fromBegin), aCString.EndWriting(fromEnd), converter); } +NS_COM +void +ToLowerCase( nsASingleFragmentCString& aCString ) + { + ConvertToLowerCase converter; + char* start; + converter.write(aCString.BeginWriting(start), aCString.Length()); + } + +NS_COM +void +ToLowerCase( nsCString& aCString ) + { + ConvertToLowerCase converter; + converter.write(aCString.mStr, aCString.mLength); + } + /** * A character sink for copying with case conversion. */