Bug 115671: Add faster To{Upper,Lower}Case for nsASingleFragment{C}String, r=dbaron, sr=dveditz, and ns{C}String, r=bbaetz, sr=scc

This commit is contained in:
jaggernaut%netscape.com 2001-12-23 02:56:41 +00:00
parent a117febf17
commit 6cb69b170f
10 changed files with 137 additions and 4 deletions

View File

@ -20,6 +20,7 @@
* Contributor(s):
* Alec Flett <alecf@netscape.com>
*/
#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:

View File

@ -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);

View File

@ -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<char>* GetFlatBufferHandle() const;

View File

@ -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<PRUnichar>* GetFlatBufferHandle() const;

View File

@ -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.
*/

View File

@ -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.
*/

View File

@ -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<char>* GetFlatBufferHandle() const;

View File

@ -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<PRUnichar>* GetFlatBufferHandle() const;

View File

@ -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.
*/

View File

@ -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.
*/