fixed: performance (memcpy used too often)
in some places there were reserve() method used (on std::wstring/std::string objects) especially in AssignString() methods if we add a new string we should check the new size and only call reserve() if the new size will be greater than existing one (plus some constant) added: Functions<>::Size() method git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@327 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
8f94937ed1
commit
33c86d494b
|
@ -87,6 +87,7 @@ public:
|
||||||
bool Find(const std::string & key, Function ** fun);
|
bool Find(const std::string & key, Function ** fun);
|
||||||
bool Find(const std::wstring & key, Function ** fun);
|
bool Find(const std::wstring & key, Function ** fun);
|
||||||
void Clear();
|
void Clear();
|
||||||
|
size_t Size();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -245,6 +246,12 @@ void Functions<StreamType>::Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class StreamType>
|
||||||
|
size_t Functions<StreamType>::Size()
|
||||||
|
{
|
||||||
|
return functions_tab.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Ezc
|
} // namespace Ezc
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,7 @@ void Pattern::SetCommentary(const std::wstring & com_start, const std::wstring &
|
||||||
void Pattern::CreateMsg(std::wstring & out, const char * type, const char * arg)
|
void Pattern::CreateMsg(std::wstring & out, const char * type, const char * arg)
|
||||||
{
|
{
|
||||||
out = commentary_start;
|
out = commentary_start;
|
||||||
out += L"EZC: ";
|
out += L"Ezc: ";
|
||||||
AssignString(type, out, false);
|
AssignString(type, out, false);
|
||||||
|
|
||||||
if( arg )
|
if( arg )
|
||||||
|
@ -295,7 +295,7 @@ void Pattern::CreateMsg(std::wstring & out, const char * type, const char * arg)
|
||||||
void Pattern::CreateMsg(std::wstring & out, const wchar_t * type, const wchar_t * arg)
|
void Pattern::CreateMsg(std::wstring & out, const wchar_t * type, const wchar_t * arg)
|
||||||
{
|
{
|
||||||
out = commentary_start;
|
out = commentary_start;
|
||||||
out += L"EZC: ";
|
out += L"Ezc: ";
|
||||||
out += type;
|
out += type;
|
||||||
|
|
||||||
if( arg )
|
if( arg )
|
||||||
|
@ -412,7 +412,7 @@ bool Pattern::ReadFileFromDir(const std::wstring & dir, const wchar_t * name, st
|
||||||
ReadFile(file, result);
|
ReadFile(file, result);
|
||||||
|
|
||||||
#ifdef EZC_USE_WINIX_LOGGER
|
#ifdef EZC_USE_WINIX_LOGGER
|
||||||
log << log3 << "EZC: read pattern: " << afile_name << logend;
|
log << log3 << "Ezc: read pattern: " << afile_name << logend;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
file_name.clear();
|
file_name.clear();
|
||||||
|
@ -932,7 +932,7 @@ void Pattern::CreateTreeReadIncludeSkipAllowFlag(Item & item)
|
||||||
if( include_level > include_level_max )
|
if( include_level > include_level_max )
|
||||||
{
|
{
|
||||||
#ifdef EZC_USE_WINIX_LOGGER
|
#ifdef EZC_USE_WINIX_LOGGER
|
||||||
log << log1 << "EZC: \"include\" directive has reached the maximum level" << logend;
|
log << log1 << "Ezc: \"include\" directive has reached the maximum level" << logend;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -51,7 +51,9 @@ size_t len;
|
||||||
dst.clear();
|
dst.clear();
|
||||||
|
|
||||||
for(len=0 ; src[len] ; ++len){}
|
for(len=0 ; src[len] ; ++len){}
|
||||||
dst.reserve(len);
|
|
||||||
|
if( dst.capacity() < dst.size() + len )
|
||||||
|
dst.reserve(dst.size() + len + 128);
|
||||||
|
|
||||||
for( ; *src ; ++src )
|
for( ; *src ; ++src )
|
||||||
dst += static_cast<unsigned char>(*src);
|
dst += static_cast<unsigned char>(*src);
|
||||||
|
@ -63,7 +65,8 @@ void AssignString(const std::string & src, std::wstring & dst, bool clear)
|
||||||
if( clear )
|
if( clear )
|
||||||
dst.clear();
|
dst.clear();
|
||||||
|
|
||||||
dst.reserve(src.size());
|
if( dst.capacity() < dst.size() + src.size() )
|
||||||
|
dst.reserve(dst.size() + src.size() + 128);
|
||||||
|
|
||||||
for(size_t i=0 ; i<src.size() ; ++i )
|
for(size_t i=0 ; i<src.size() ; ++i )
|
||||||
dst += static_cast<unsigned char>(src[i]);
|
dst += static_cast<unsigned char>(src[i]);
|
||||||
|
@ -78,7 +81,9 @@ size_t len;
|
||||||
dst.clear();
|
dst.clear();
|
||||||
|
|
||||||
for(len=0 ; src[len] ; ++len){}
|
for(len=0 ; src[len] ; ++len){}
|
||||||
dst.reserve(len);
|
|
||||||
|
if( dst.capacity() < dst.size() + len )
|
||||||
|
dst.reserve(dst.size() + len + 128);
|
||||||
|
|
||||||
for( ; *src ; ++src )
|
for( ; *src ; ++src )
|
||||||
dst += static_cast<char>(*src);
|
dst += static_cast<char>(*src);
|
||||||
|
@ -90,7 +95,8 @@ void AssignString(const std::wstring & src, std::string & dst, bool clear)
|
||||||
if( clear )
|
if( clear )
|
||||||
dst.clear();
|
dst.clear();
|
||||||
|
|
||||||
dst.reserve(src.size());
|
if( dst.capacity() < dst.size() + src.size() )
|
||||||
|
dst.reserve(dst.size() + src.size() + 128);
|
||||||
|
|
||||||
for(size_t i=0 ; i<src.size() ; ++i )
|
for(size_t i=0 ; i<src.size() ; ++i )
|
||||||
dst += static_cast<char>(src[i]);
|
dst += static_cast<char>(src[i]);
|
||||||
|
|
Loading…
Reference in New Issue