mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-14 22:03:30 -06:00
Core: Minor StringBuffer optimisation
git-svn-id: svn://ultimatepp.org/upp/trunk@14891 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
f8eeea5a6b
commit
09f2a25251
3 changed files with 23 additions and 15 deletions
|
|
@ -288,6 +288,26 @@ void StringBuffer::Strlen()
|
|||
SetLength((int)strlen__(pbegin));
|
||||
}
|
||||
|
||||
inline
|
||||
void StringBuffer::Cat(const char *s, int l)
|
||||
{
|
||||
if(pend + l > limit)
|
||||
ReallocL(s, l);
|
||||
else {
|
||||
memcpy8(pend, s, l);
|
||||
pend += l;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void StringBuffer::Cat(int c, int l)
|
||||
{
|
||||
if(pend + l > limit)
|
||||
ReallocL(NULL, l);
|
||||
memset8(pend, c, l);
|
||||
pend += l;
|
||||
}
|
||||
|
||||
force_inline
|
||||
void StringBuffer::Cat(const char *s)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -416,22 +416,9 @@ void StringBuffer::Shrink()
|
|||
pend = pbegin + l;
|
||||
}
|
||||
|
||||
void StringBuffer::Cat(const char *s, int l)
|
||||
void StringBuffer::ReallocL(const char *s, int l)
|
||||
{
|
||||
if(pend + l > limit)
|
||||
Realloc(max(GetLength(), l) + GetLength(), s, l);
|
||||
else {
|
||||
memcpy8(pend, s, l);
|
||||
pend += l;
|
||||
}
|
||||
}
|
||||
|
||||
void StringBuffer::Cat(int c, int l)
|
||||
{
|
||||
if(pend + l > limit)
|
||||
Realloc(max(GetLength(), l) + GetLength(), NULL, l);
|
||||
memset(pend, c, l);
|
||||
pend += l;
|
||||
Realloc(max(GetLength(), l) + GetLength(), s, l);
|
||||
}
|
||||
|
||||
void StringBuffer::Set(String& s)
|
||||
|
|
|
|||
|
|
@ -408,6 +408,7 @@ class StringBuffer : NoCopy {
|
|||
|
||||
char *Alloc(int len, int& alloc);
|
||||
void Realloc(dword n, const char *cat = NULL, int l = 0);
|
||||
void ReallocL(const char *s, int l);
|
||||
void Expand();
|
||||
void Zero() { pbegin = pend = buffer; limit = pbegin + 255; }
|
||||
void Free();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue