Some small optimizations
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1126 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -451,9 +451,8 @@ BString::RemoveFirst(const char *str)
|
|||||||
{
|
{
|
||||||
if (str) {
|
if (str) {
|
||||||
int32 pos = _FindAfter(str, 0, -1);
|
int32 pos = _FindAfter(str, 0, -1);
|
||||||
int32 len = strlen(str);
|
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
_privateData = _ShrinkAtBy(pos, len);
|
_privateData = _ShrinkAtBy(pos, strlen(str));
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -610,11 +609,8 @@ BString::FindFirst(const char *string, int32 fromOffset) const
|
|||||||
int32
|
int32
|
||||||
BString::FindFirst(char c) const
|
BString::FindFirst(char c) const
|
||||||
{
|
{
|
||||||
char *tmp = (char*)malloc(2);
|
char tmp[2] = { c, '\0' };
|
||||||
tmp[0] = c;
|
|
||||||
tmp[1] = '\0';
|
|
||||||
int32 result = _FindAfter(tmp, 0, -1);
|
int32 result = _FindAfter(tmp, 0, -1);
|
||||||
free(tmp);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -623,11 +619,8 @@ BString::FindFirst(char c) const
|
|||||||
int32
|
int32
|
||||||
BString::FindFirst(char c, int32 fromOffset) const
|
BString::FindFirst(char c, int32 fromOffset) const
|
||||||
{
|
{
|
||||||
char *tmp = (char*)malloc(2);
|
char tmp[2] = { c, '\0' };
|
||||||
tmp[0] = c;
|
|
||||||
tmp[1] = '\0';
|
|
||||||
int32 result = _FindAfter(tmp, fromOffset, -1);
|
int32 result = _FindAfter(tmp, fromOffset, -1);
|
||||||
free(tmp);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -814,9 +807,7 @@ BString::UnlockBuffer(int32 length)
|
|||||||
BString&
|
BString&
|
||||||
BString::ToLower()
|
BString::ToLower()
|
||||||
{
|
{
|
||||||
int count = 0;
|
for (int count = 0; count < Length(); count++)
|
||||||
for (; count < Length(); count++)
|
|
||||||
if (isalpha(_privateData[count]))
|
|
||||||
_privateData[count] = tolower(_privateData[count]);
|
_privateData[count] = tolower(_privateData[count]);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@@ -826,9 +817,7 @@ BString::ToLower()
|
|||||||
BString&
|
BString&
|
||||||
BString::ToUpper()
|
BString::ToUpper()
|
||||||
{
|
{
|
||||||
int count = 0;
|
for (int count = 0; count < Length(); count++)
|
||||||
for (; count < Length(); count++)
|
|
||||||
if (isalpha(_privateData[count]))
|
|
||||||
_privateData[count] = toupper(_privateData[count]);
|
_privateData[count] = toupper(_privateData[count]);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@@ -838,8 +827,8 @@ BString::ToUpper()
|
|||||||
BString&
|
BString&
|
||||||
BString::Capitalize()
|
BString::Capitalize()
|
||||||
{
|
{
|
||||||
int count = 0;
|
|
||||||
for (; count < Length(); count++)
|
for (int count = 0; count < Length(); count++)
|
||||||
if (isalpha(_privateData[count])) {
|
if (isalpha(_privateData[count])) {
|
||||||
_privateData[count] = toupper(_privateData[count]);
|
_privateData[count] = toupper(_privateData[count]);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user