From 7c4f6b329354cb5aa81248b11c2b8f4706bfb460 Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Sun, 12 Mar 2000 11:10:07 +0000 Subject: [PATCH] landing phase 2 to remove deprecated string calls --- content/html/style/src/nsCSSLoader.cpp | 6 +-- content/html/style/src/nsCSSStyleSheet.cpp | 6 +-- content/html/style/src/nsHTMLAttributes.cpp | 4 +- dom/src/base/nsGlobalWindow.cpp | 2 +- editor/base/nsHTMLEditRules.cpp | 2 +- editor/base/nsHTMLEditorLog.cpp | 2 +- editor/libeditor/html/nsHTMLEditRules.cpp | 2 +- editor/libeditor/html/nsHTMLEditorLog.cpp | 2 +- gfx/src/nsColorNames.cpp | 15 ++----- gfx/src/nsFont.cpp | 2 +- layout/html/style/src/nsCSSLoader.cpp | 6 +-- layout/html/style/src/nsCSSStyleSheet.cpp | 6 +-- layout/html/style/src/nsHTMLAttributes.cpp | 4 +- layout/style/nsCSSLoader.cpp | 6 +-- layout/style/nsCSSStyleSheet.cpp | 6 +-- string/obsolete/nsString.cpp | 45 ------------------- string/obsolete/nsString.h | 19 -------- string/obsolete/nsString2.cpp | 50 --------------------- string/obsolete/nsString2.h | 18 -------- xpcom/ds/nsHashtable.cpp | 7 ++- xpcom/ds/nsHashtable.h | 3 +- xpcom/ds/nsString.cpp | 45 ------------------- xpcom/ds/nsString.h | 19 -------- xpcom/ds/nsString2.cpp | 50 --------------------- xpcom/ds/nsString2.h | 18 -------- xpcom/string/obsolete/nsString.cpp | 45 ------------------- xpcom/string/obsolete/nsString.h | 19 -------- xpcom/string/obsolete/nsString2.cpp | 50 --------------------- xpcom/string/obsolete/nsString2.h | 18 -------- 29 files changed, 38 insertions(+), 439 deletions(-) diff --git a/content/html/style/src/nsCSSLoader.cpp b/content/html/style/src/nsCSSLoader.cpp index 7ea2d3a3f5c..75d17490bb5 100644 --- a/content/html/style/src/nsCSSLoader.cpp +++ b/content/html/style/src/nsCSSLoader.cpp @@ -853,7 +853,7 @@ static PRBool EnumerateMediaString(const nsString& aStringList, nsStringEnumFunc while (running && (kNullCh != *start)) { PRBool quoted = PR_FALSE; - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } @@ -884,8 +884,8 @@ static PRBool EnumerateMediaString(const nsString& aStringList, nsStringEnumFunc // truncate at first non letter, digit or hyphen PRUnichar* test = start; while (test <= end) { - if ((PR_FALSE == nsString::IsAlpha(*test)) && - (PR_FALSE == nsString::IsDigit(*test)) && (kMinus != *test)) { + if ((PR_FALSE == nsCRT::IsAsciiAlpha(*test)) && + (PR_FALSE == nsCRT::IsAsciiDigit(*test)) && (kMinus != *test)) { *test = kNullCh; break; } diff --git a/content/html/style/src/nsCSSStyleSheet.cpp b/content/html/style/src/nsCSSStyleSheet.cpp index 2938bf9e5ff..eedd5ab886d 100644 --- a/content/html/style/src/nsCSSStyleSheet.cpp +++ b/content/html/style/src/nsCSSStyleSheet.cpp @@ -2198,12 +2198,12 @@ static PRBool ValueIncludes(const nsString& aValueList, const nsString& aValue, PRUnichar* end = start; while (kNullCh != *start) { - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } end = start; - while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end + while ((kNullCh != *end) && (PR_FALSE == nsCRT::IsAsciiSpace(*end))) { // look for space or end end++; } *end = kNullCh; // end string here @@ -2239,7 +2239,7 @@ static PRBool ValueDashMatch(const nsString& aValueList, const nsString& aValue, PRUnichar* end = start; if (kNullCh != *start) { - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } end = start; diff --git a/content/html/style/src/nsHTMLAttributes.cpp b/content/html/style/src/nsHTMLAttributes.cpp index 24723d3644e..b075ad6de63 100644 --- a/content/html/style/src/nsHTMLAttributes.cpp +++ b/content/html/style/src/nsHTMLAttributes.cpp @@ -978,12 +978,12 @@ static void ParseClasses(const nsString& aClassString, nsClassList& aClassList) nsClassList* list = &aClassList; while (list && (kNullCh != *start)) { - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } end = start; - while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end + while ((kNullCh != *end) && (PR_FALSE == nsCRT::IsAsciiSpace(*end))) { // look for space or end end++; } *end = kNullCh; // end string here diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index c6feb2932d8..60b238dd668 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -2771,7 +2771,7 @@ NS_IMETHODIMP GlobalWindowImpl::CheckWindowName(JSContext* cx, nsString& aName) for(strIndex = 0; strIndex < aName.Length(); strIndex++) { mChar = aName.CharAt(strIndex); - if(!nsString::IsAlpha(mChar) && !nsString::IsDigit(mChar) && + if(!nsCRT::IsAsciiAlpha(mChar) && !nsCRT::IsAsciiDigit(mChar) && mChar != '_') { char* cp = aName.ToNewCString(); diff --git a/editor/base/nsHTMLEditRules.cpp b/editor/base/nsHTMLEditRules.cpp index e6d49be0873..ce278cb157c 100644 --- a/editor/base/nsHTMLEditRules.cpp +++ b/editor/base/nsHTMLEditRules.cpp @@ -3823,7 +3823,7 @@ nsHTMLEditRules::DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aS PRInt32 runStart = -1, runEnd = -1; do { PRUnichar c = tempString[j]; - PRBool isSpace = nsString::IsSpace(c); + PRBool isSpace = nsCRT::IsAsciiSpace(c); if (isSpace || c==nbsp) { if (runStart<0) runStart = j; diff --git a/editor/base/nsHTMLEditorLog.cpp b/editor/base/nsHTMLEditorLog.cpp index 0b7f083c5a1..ef95d6fb919 100644 --- a/editor/base/nsHTMLEditorLog.cpp +++ b/editor/base/nsHTMLEditorLog.cpp @@ -909,7 +909,7 @@ nsHTMLEditorLog::PrintUnicode(const nsString &aString) for (i = 0; i < len; i++) { - if (nsString::IsAlpha(uc[i]) || nsString::IsDigit(uc[i]) || uc[i] == ' ') + if (nsCRT::IsAsciiAlpha(uc[i]) || nsCRT::IsAsciiDigit(uc[i]) || uc[i] == ' ') sprintf(buf, "%c", uc[i]); else sprintf(buf, "\\u%.4x", uc[i]); diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index e6d49be0873..ce278cb157c 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -3823,7 +3823,7 @@ nsHTMLEditRules::DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aS PRInt32 runStart = -1, runEnd = -1; do { PRUnichar c = tempString[j]; - PRBool isSpace = nsString::IsSpace(c); + PRBool isSpace = nsCRT::IsAsciiSpace(c); if (isSpace || c==nbsp) { if (runStart<0) runStart = j; diff --git a/editor/libeditor/html/nsHTMLEditorLog.cpp b/editor/libeditor/html/nsHTMLEditorLog.cpp index 0b7f083c5a1..ef95d6fb919 100644 --- a/editor/libeditor/html/nsHTMLEditorLog.cpp +++ b/editor/libeditor/html/nsHTMLEditorLog.cpp @@ -909,7 +909,7 @@ nsHTMLEditorLog::PrintUnicode(const nsString &aString) for (i = 0; i < len; i++) { - if (nsString::IsAlpha(uc[i]) || nsString::IsDigit(uc[i]) || uc[i] == ' ') + if (nsCRT::IsAsciiAlpha(uc[i]) || nsCRT::IsAsciiDigit(uc[i]) || uc[i] == ' ') sprintf(buf, "%c", uc[i]); else sprintf(buf, "\\u%.4x", uc[i]); diff --git a/gfx/src/nsColorNames.cpp b/gfx/src/nsColorNames.cpp index b46598469c8..39f9ae16035 100644 --- a/gfx/src/nsColorNames.cpp +++ b/gfx/src/nsColorNames.cpp @@ -132,18 +132,9 @@ nsColorNames::LookupName(const nsCString& aColorName) } nsColorName -nsColorNames::LookupName(const nsString& aColorName) -{ - NS_ASSERTION(gColorTree, "no lookup table, needs addref"); - if (gColorTree) { - ColorNode node(aColorName, eColorName_UNKNOWN); - ColorNode* found = (ColorNode*)gColorTree->FindItem(&node); - if (found) { - NS_ASSERTION(found->mStr.EqualsIgnoreCase(aColorName), "bad tree"); - return found->mEnum; - } - } - return eColorName_UNKNOWN; +nsColorNames::LookupName(const nsString& aColorName) { + nsCAutoString theName(aColorName); + return LookupName(theName); } diff --git a/gfx/src/nsFont.cpp b/gfx/src/nsFont.cpp index 4891040ce33..c927294c55b 100644 --- a/gfx/src/nsFont.cpp +++ b/gfx/src/nsFont.cpp @@ -116,7 +116,7 @@ PRBool nsFont::EnumerateFamilies(nsFontFamilyEnumFunc aFunc, void* aData) const PRBool quoted = PR_FALSE; PRBool generic = PR_FALSE; - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } diff --git a/layout/html/style/src/nsCSSLoader.cpp b/layout/html/style/src/nsCSSLoader.cpp index 7ea2d3a3f5c..75d17490bb5 100644 --- a/layout/html/style/src/nsCSSLoader.cpp +++ b/layout/html/style/src/nsCSSLoader.cpp @@ -853,7 +853,7 @@ static PRBool EnumerateMediaString(const nsString& aStringList, nsStringEnumFunc while (running && (kNullCh != *start)) { PRBool quoted = PR_FALSE; - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } @@ -884,8 +884,8 @@ static PRBool EnumerateMediaString(const nsString& aStringList, nsStringEnumFunc // truncate at first non letter, digit or hyphen PRUnichar* test = start; while (test <= end) { - if ((PR_FALSE == nsString::IsAlpha(*test)) && - (PR_FALSE == nsString::IsDigit(*test)) && (kMinus != *test)) { + if ((PR_FALSE == nsCRT::IsAsciiAlpha(*test)) && + (PR_FALSE == nsCRT::IsAsciiDigit(*test)) && (kMinus != *test)) { *test = kNullCh; break; } diff --git a/layout/html/style/src/nsCSSStyleSheet.cpp b/layout/html/style/src/nsCSSStyleSheet.cpp index 2938bf9e5ff..eedd5ab886d 100644 --- a/layout/html/style/src/nsCSSStyleSheet.cpp +++ b/layout/html/style/src/nsCSSStyleSheet.cpp @@ -2198,12 +2198,12 @@ static PRBool ValueIncludes(const nsString& aValueList, const nsString& aValue, PRUnichar* end = start; while (kNullCh != *start) { - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } end = start; - while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end + while ((kNullCh != *end) && (PR_FALSE == nsCRT::IsAsciiSpace(*end))) { // look for space or end end++; } *end = kNullCh; // end string here @@ -2239,7 +2239,7 @@ static PRBool ValueDashMatch(const nsString& aValueList, const nsString& aValue, PRUnichar* end = start; if (kNullCh != *start) { - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } end = start; diff --git a/layout/html/style/src/nsHTMLAttributes.cpp b/layout/html/style/src/nsHTMLAttributes.cpp index 24723d3644e..b075ad6de63 100644 --- a/layout/html/style/src/nsHTMLAttributes.cpp +++ b/layout/html/style/src/nsHTMLAttributes.cpp @@ -978,12 +978,12 @@ static void ParseClasses(const nsString& aClassString, nsClassList& aClassList) nsClassList* list = &aClassList; while (list && (kNullCh != *start)) { - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } end = start; - while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end + while ((kNullCh != *end) && (PR_FALSE == nsCRT::IsAsciiSpace(*end))) { // look for space or end end++; } *end = kNullCh; // end string here diff --git a/layout/style/nsCSSLoader.cpp b/layout/style/nsCSSLoader.cpp index 7ea2d3a3f5c..75d17490bb5 100644 --- a/layout/style/nsCSSLoader.cpp +++ b/layout/style/nsCSSLoader.cpp @@ -853,7 +853,7 @@ static PRBool EnumerateMediaString(const nsString& aStringList, nsStringEnumFunc while (running && (kNullCh != *start)) { PRBool quoted = PR_FALSE; - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } @@ -884,8 +884,8 @@ static PRBool EnumerateMediaString(const nsString& aStringList, nsStringEnumFunc // truncate at first non letter, digit or hyphen PRUnichar* test = start; while (test <= end) { - if ((PR_FALSE == nsString::IsAlpha(*test)) && - (PR_FALSE == nsString::IsDigit(*test)) && (kMinus != *test)) { + if ((PR_FALSE == nsCRT::IsAsciiAlpha(*test)) && + (PR_FALSE == nsCRT::IsAsciiDigit(*test)) && (kMinus != *test)) { *test = kNullCh; break; } diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index 2938bf9e5ff..eedd5ab886d 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -2198,12 +2198,12 @@ static PRBool ValueIncludes(const nsString& aValueList, const nsString& aValue, PRUnichar* end = start; while (kNullCh != *start) { - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } end = start; - while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end + while ((kNullCh != *end) && (PR_FALSE == nsCRT::IsAsciiSpace(*end))) { // look for space or end end++; } *end = kNullCh; // end string here @@ -2239,7 +2239,7 @@ static PRBool ValueDashMatch(const nsString& aValueList, const nsString& aValue, PRUnichar* end = start; if (kNullCh != *start) { - while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space + while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space start++; } end = start; diff --git a/string/obsolete/nsString.cpp b/string/obsolete/nsString.cpp index 58f9d66b8a7..342077ce712 100644 --- a/string/obsolete/nsString.cpp +++ b/string/obsolete/nsString.cpp @@ -143,27 +143,6 @@ void nsCString::Truncate(PRUint32 anIndex) { nsStr::Truncate(*this,anIndex); } -/** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @update gess 8/25/98 - * @return TRUE if ordered. - */ -PRBool nsCString::IsOrdered(void) const { - PRBool result=PR_TRUE; - if(mLength>1) { - PRUint32 theIndex; - for(theIndex=1;theIndexmStr[theIndex]) { - result=PR_FALSE; - break; - } - } - } - return result; -} - /** * Call this method if you want to force the string to a certain capacity @@ -1205,30 +1184,6 @@ nsCString& nsCString::Cut(PRUint32 anOffset, PRInt32 aCount) { Searching methods... *********************************************************************/ -/** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ -PRInt32 nsCString::BinarySearch(PRUnichar aChar) const{ - PRInt32 low=0; - PRInt32 high=mLength-1; - - while (low <= high) { - int middle = (low + high) >> 1; - PRUnichar theChar=GetCharAt(*this,middle); - if (theChar==aChar) - return middle; - if (theChar>aChar) - high = middle - 1; - else - low = middle + 1; - } - return kNotFound; -} /** * Search for given cstr within this string diff --git a/string/obsolete/nsString.h b/string/obsolete/nsString.h index 78c405a2be0..c22566b1269 100644 --- a/string/obsolete/nsString.h +++ b/string/obsolete/nsString.h @@ -130,16 +130,6 @@ public: */ void Truncate(PRUint32 anIndex=0); - - /** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @return TRUE if ordered. - */ - PRBool IsOrdered(void) const; - - /** * Determine whether or not this string has a length of 0 * @@ -516,15 +506,6 @@ public: Searching methods... *********************************************************************/ - /** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ - PRInt32 BinarySearch(PRUnichar aChar) const; /** * Search for given substring within this string diff --git a/string/obsolete/nsString2.cpp b/string/obsolete/nsString2.cpp index cd49a01279d..e8a09208970 100644 --- a/string/obsolete/nsString2.cpp +++ b/string/obsolete/nsString2.cpp @@ -153,31 +153,6 @@ void nsString::Truncate(PRUint32 anIndex) { nsStr::Truncate(*this,anIndex); } -/** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @update gess 8/25/98 - * @return TRUE if ordered. - */ -PRBool nsString::IsOrdered(void) const { - PRBool result=PR_TRUE; - if(mLength>1) { - PRUint32 theIndex; - PRUnichar c1=0; - PRUnichar c2=GetCharAt(*this,0); - for(theIndex=1;theIndexc2) { - result=PR_FALSE; - break; - } - } - } - return result; -} - /** * Call this method if you want to force the string to a certain capacity @@ -1411,31 +1386,6 @@ nsString& nsString::Cut(PRUint32 anOffset, PRInt32 aCount) { Searching methods... *********************************************************************/ -/** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ -PRInt32 nsString::BinarySearch(PRUnichar aChar) const{ - PRInt32 low=0; - PRInt32 high=mLength-1; - - while (low <= high) { - int middle = (low + high) >> 1; - PRUnichar theChar=GetCharAt(*this,middle); - if (theChar==aChar) - return middle; - if (theChar>aChar) - high = middle - 1; - else - low = middle + 1; - } - return kNotFound; -} - /** * search for given string within this string * diff --git a/string/obsolete/nsString2.h b/string/obsolete/nsString2.h index 1b8221849c8..f09066e1c9b 100644 --- a/string/obsolete/nsString2.h +++ b/string/obsolete/nsString2.h @@ -144,14 +144,6 @@ public: void Truncate(PRUint32 anIndex=0); - /** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @return TRUE if ordered. - */ - PRBool IsOrdered(void) const; - /** * Determine whether or not the characters in this * string are in store as 1 or 2 byte (unicode) strings. @@ -566,16 +558,6 @@ public: Searching methods... *********************************************************************/ - /** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ - PRInt32 BinarySearch(PRUnichar aChar) const; - /** * Search for given substring within this string * diff --git a/xpcom/ds/nsHashtable.cpp b/xpcom/ds/nsHashtable.cpp index e635c6a1fd0..1a07b1e0a2e 100644 --- a/xpcom/ds/nsHashtable.cpp +++ b/xpcom/ds/nsHashtable.cpp @@ -258,8 +258,11 @@ nsStringKey::nsStringKey(const PRUnichar* str) mStr.Assign(str); } -nsStringKey::nsStringKey(const nsStr& str) -{ +nsStringKey::nsStringKey(const nsString& str) { + mStr.Assign(str); +} + +nsStringKey::nsStringKey(const nsCString& str) { mStr.Assign(str); } diff --git a/xpcom/ds/nsHashtable.h b/xpcom/ds/nsHashtable.h index 37cce188ece..c2947f27b4e 100644 --- a/xpcom/ds/nsHashtable.h +++ b/xpcom/ds/nsHashtable.h @@ -203,7 +203,8 @@ protected: public: nsStringKey(const char* str); nsStringKey(const PRUnichar* str); - nsStringKey(const nsStr& str); + nsStringKey(const nsString& str); + nsStringKey(const nsCString& str); ~nsStringKey(void); diff --git a/xpcom/ds/nsString.cpp b/xpcom/ds/nsString.cpp index 58f9d66b8a7..342077ce712 100644 --- a/xpcom/ds/nsString.cpp +++ b/xpcom/ds/nsString.cpp @@ -143,27 +143,6 @@ void nsCString::Truncate(PRUint32 anIndex) { nsStr::Truncate(*this,anIndex); } -/** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @update gess 8/25/98 - * @return TRUE if ordered. - */ -PRBool nsCString::IsOrdered(void) const { - PRBool result=PR_TRUE; - if(mLength>1) { - PRUint32 theIndex; - for(theIndex=1;theIndexmStr[theIndex]) { - result=PR_FALSE; - break; - } - } - } - return result; -} - /** * Call this method if you want to force the string to a certain capacity @@ -1205,30 +1184,6 @@ nsCString& nsCString::Cut(PRUint32 anOffset, PRInt32 aCount) { Searching methods... *********************************************************************/ -/** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ -PRInt32 nsCString::BinarySearch(PRUnichar aChar) const{ - PRInt32 low=0; - PRInt32 high=mLength-1; - - while (low <= high) { - int middle = (low + high) >> 1; - PRUnichar theChar=GetCharAt(*this,middle); - if (theChar==aChar) - return middle; - if (theChar>aChar) - high = middle - 1; - else - low = middle + 1; - } - return kNotFound; -} /** * Search for given cstr within this string diff --git a/xpcom/ds/nsString.h b/xpcom/ds/nsString.h index 78c405a2be0..c22566b1269 100644 --- a/xpcom/ds/nsString.h +++ b/xpcom/ds/nsString.h @@ -130,16 +130,6 @@ public: */ void Truncate(PRUint32 anIndex=0); - - /** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @return TRUE if ordered. - */ - PRBool IsOrdered(void) const; - - /** * Determine whether or not this string has a length of 0 * @@ -516,15 +506,6 @@ public: Searching methods... *********************************************************************/ - /** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ - PRInt32 BinarySearch(PRUnichar aChar) const; /** * Search for given substring within this string diff --git a/xpcom/ds/nsString2.cpp b/xpcom/ds/nsString2.cpp index cd49a01279d..e8a09208970 100644 --- a/xpcom/ds/nsString2.cpp +++ b/xpcom/ds/nsString2.cpp @@ -153,31 +153,6 @@ void nsString::Truncate(PRUint32 anIndex) { nsStr::Truncate(*this,anIndex); } -/** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @update gess 8/25/98 - * @return TRUE if ordered. - */ -PRBool nsString::IsOrdered(void) const { - PRBool result=PR_TRUE; - if(mLength>1) { - PRUint32 theIndex; - PRUnichar c1=0; - PRUnichar c2=GetCharAt(*this,0); - for(theIndex=1;theIndexc2) { - result=PR_FALSE; - break; - } - } - } - return result; -} - /** * Call this method if you want to force the string to a certain capacity @@ -1411,31 +1386,6 @@ nsString& nsString::Cut(PRUint32 anOffset, PRInt32 aCount) { Searching methods... *********************************************************************/ -/** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ -PRInt32 nsString::BinarySearch(PRUnichar aChar) const{ - PRInt32 low=0; - PRInt32 high=mLength-1; - - while (low <= high) { - int middle = (low + high) >> 1; - PRUnichar theChar=GetCharAt(*this,middle); - if (theChar==aChar) - return middle; - if (theChar>aChar) - high = middle - 1; - else - low = middle + 1; - } - return kNotFound; -} - /** * search for given string within this string * diff --git a/xpcom/ds/nsString2.h b/xpcom/ds/nsString2.h index 1b8221849c8..f09066e1c9b 100644 --- a/xpcom/ds/nsString2.h +++ b/xpcom/ds/nsString2.h @@ -144,14 +144,6 @@ public: void Truncate(PRUint32 anIndex=0); - /** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @return TRUE if ordered. - */ - PRBool IsOrdered(void) const; - /** * Determine whether or not the characters in this * string are in store as 1 or 2 byte (unicode) strings. @@ -566,16 +558,6 @@ public: Searching methods... *********************************************************************/ - /** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ - PRInt32 BinarySearch(PRUnichar aChar) const; - /** * Search for given substring within this string * diff --git a/xpcom/string/obsolete/nsString.cpp b/xpcom/string/obsolete/nsString.cpp index 58f9d66b8a7..342077ce712 100644 --- a/xpcom/string/obsolete/nsString.cpp +++ b/xpcom/string/obsolete/nsString.cpp @@ -143,27 +143,6 @@ void nsCString::Truncate(PRUint32 anIndex) { nsStr::Truncate(*this,anIndex); } -/** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @update gess 8/25/98 - * @return TRUE if ordered. - */ -PRBool nsCString::IsOrdered(void) const { - PRBool result=PR_TRUE; - if(mLength>1) { - PRUint32 theIndex; - for(theIndex=1;theIndexmStr[theIndex]) { - result=PR_FALSE; - break; - } - } - } - return result; -} - /** * Call this method if you want to force the string to a certain capacity @@ -1205,30 +1184,6 @@ nsCString& nsCString::Cut(PRUint32 anOffset, PRInt32 aCount) { Searching methods... *********************************************************************/ -/** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ -PRInt32 nsCString::BinarySearch(PRUnichar aChar) const{ - PRInt32 low=0; - PRInt32 high=mLength-1; - - while (low <= high) { - int middle = (low + high) >> 1; - PRUnichar theChar=GetCharAt(*this,middle); - if (theChar==aChar) - return middle; - if (theChar>aChar) - high = middle - 1; - else - low = middle + 1; - } - return kNotFound; -} /** * Search for given cstr within this string diff --git a/xpcom/string/obsolete/nsString.h b/xpcom/string/obsolete/nsString.h index 78c405a2be0..c22566b1269 100644 --- a/xpcom/string/obsolete/nsString.h +++ b/xpcom/string/obsolete/nsString.h @@ -130,16 +130,6 @@ public: */ void Truncate(PRUint32 anIndex=0); - - /** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @return TRUE if ordered. - */ - PRBool IsOrdered(void) const; - - /** * Determine whether or not this string has a length of 0 * @@ -516,15 +506,6 @@ public: Searching methods... *********************************************************************/ - /** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ - PRInt32 BinarySearch(PRUnichar aChar) const; /** * Search for given substring within this string diff --git a/xpcom/string/obsolete/nsString2.cpp b/xpcom/string/obsolete/nsString2.cpp index cd49a01279d..e8a09208970 100644 --- a/xpcom/string/obsolete/nsString2.cpp +++ b/xpcom/string/obsolete/nsString2.cpp @@ -153,31 +153,6 @@ void nsString::Truncate(PRUint32 anIndex) { nsStr::Truncate(*this,anIndex); } -/** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @update gess 8/25/98 - * @return TRUE if ordered. - */ -PRBool nsString::IsOrdered(void) const { - PRBool result=PR_TRUE; - if(mLength>1) { - PRUint32 theIndex; - PRUnichar c1=0; - PRUnichar c2=GetCharAt(*this,0); - for(theIndex=1;theIndexc2) { - result=PR_FALSE; - break; - } - } - } - return result; -} - /** * Call this method if you want to force the string to a certain capacity @@ -1411,31 +1386,6 @@ nsString& nsString::Cut(PRUint32 anOffset, PRInt32 aCount) { Searching methods... *********************************************************************/ -/** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ -PRInt32 nsString::BinarySearch(PRUnichar aChar) const{ - PRInt32 low=0; - PRInt32 high=mLength-1; - - while (low <= high) { - int middle = (low + high) >> 1; - PRUnichar theChar=GetCharAt(*this,middle); - if (theChar==aChar) - return middle; - if (theChar>aChar) - high = middle - 1; - else - low = middle + 1; - } - return kNotFound; -} - /** * search for given string within this string * diff --git a/xpcom/string/obsolete/nsString2.h b/xpcom/string/obsolete/nsString2.h index 1b8221849c8..f09066e1c9b 100644 --- a/xpcom/string/obsolete/nsString2.h +++ b/xpcom/string/obsolete/nsString2.h @@ -144,14 +144,6 @@ public: void Truncate(PRUint32 anIndex=0); - /** - * Determine whether or not the characters in this - * string are in sorted order. - * - * @return TRUE if ordered. - */ - PRBool IsOrdered(void) const; - /** * Determine whether or not the characters in this * string are in store as 1 or 2 byte (unicode) strings. @@ -566,16 +558,6 @@ public: Searching methods... *********************************************************************/ - /** - * Search for given character within this string. - * This method does so by using a binary search, - * so your string HAD BETTER BE ORDERED! - * - * @param aChar is the unicode char to be found - * @return offset in string, or -1 (kNotFound) - */ - PRInt32 BinarySearch(PRUnichar aChar) const; - /** * Search for given substring within this string *