* Small speedups in mempool/dotconfpp.

--HG--
branch : trunk
This commit is contained in:
XTZGZoReX
2009-03-19 15:42:53 +01:00
parent a075d37fdd
commit 2f9688bb07
2 changed files with 13 additions and 13 deletions
+10 -10
View File
@@ -55,13 +55,13 @@ DOTCONFDocument::DOTCONFDocument(DOTCONFDocument::CaseSensitive caseSensitivity)
DOTCONFDocument::~DOTCONFDocument() DOTCONFDocument::~DOTCONFDocument()
{ {
for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i != nodeTree.end(); i++){ for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i != nodeTree.end(); ++i){
delete(*i); delete(*i);
} }
for(std::list<char*>::iterator i = requiredOptions.begin(); i != requiredOptions.end(); i++){ for(std::list<char*>::iterator i = requiredOptions.begin(); i != requiredOptions.end(); ++i){
free(*i); free(*i);
} }
for(std::list<char*>::iterator i = processedFiles.begin(); i != processedFiles.end(); i++){ for(std::list<char*>::iterator i = processedFiles.begin(); i != processedFiles.end(); ++i){
free(*i); free(*i);
} }
free(fileName); free(fileName);
@@ -177,7 +177,7 @@ int DOTCONFDocument::parseLine()
DOTCONFDocumentNode * tagNode = NULL; DOTCONFDocumentNode * tagNode = NULL;
bool newNode = false; bool newNode = false;
for(std::list<char*>::iterator i = words.begin(); i != words.end(); i++) { for(std::list<char*>::iterator i = words.begin(); i != words.end(); ++i) {
word = *i; word = *i;
if(*word == '<'){ if(*word == '<'){
@@ -295,7 +295,7 @@ int DOTCONFDocument::checkConfig(const std::list<DOTCONFDocumentNode*>::iterator
DOTCONFDocumentNode * tagNode = NULL; DOTCONFDocumentNode * tagNode = NULL;
int vi = 0; int vi = 0;
for(std::list<DOTCONFDocumentNode*>::iterator i = from; i != nodeTree.end(); i++){ for(std::list<DOTCONFDocumentNode*>::iterator i = from; i != nodeTree.end(); ++i){
tagNode = *i; tagNode = *i;
if(!tagNode->closed){ if(!tagNode->closed){
error(tagNode->lineNum, tagNode->fileName, "unclosed tag %s", tagNode->name); error(tagNode->lineNum, tagNode->fileName, "unclosed tag %s", tagNode->name);
@@ -359,7 +359,7 @@ int DOTCONFDocument::setContent(const char * _fileName)
std::list<DOTCONFDocumentNode*>::iterator from; std::list<DOTCONFDocumentNode*>::iterator from;
DOTCONFDocumentNode * tagNode = NULL; DOTCONFDocumentNode * tagNode = NULL;
int vi = 0; int vi = 0;
for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i!=nodeTree.end(); i++){ for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i!=nodeTree.end(); ++i){
tagNode = *i; tagNode = *i;
if(!cmp_func("DOTCONFPPIncludeFile", tagNode->name)){ if(!cmp_func("DOTCONFPPIncludeFile", tagNode->name)){
vi = 0; vi = 0;
@@ -374,7 +374,7 @@ int DOTCONFDocument::setContent(const char * _fileName)
} }
bool processed = false; bool processed = false;
for(std::list<char*>::const_iterator itInode = processedFiles.begin(); itInode != processedFiles.end(); itInode++){ for(std::list<char*>::const_iterator itInode = processedFiles.begin(); itInode != processedFiles.end(); ++itInode){
if(!strcmp(*itInode, realpathBuf)){ if(!strcmp(*itInode, realpathBuf)){
processed = true; processed = true;
break; break;
@@ -417,9 +417,9 @@ int DOTCONFDocument::setContent(const char * _fileName)
int DOTCONFDocument::checkRequiredOptions() int DOTCONFDocument::checkRequiredOptions()
{ {
for(std::list<char*>::const_iterator ci = requiredOptions.begin(); ci != requiredOptions.end(); ci++){ for(std::list<char*>::const_iterator ci = requiredOptions.begin(); ci != requiredOptions.end(); ++ci){
bool matched = false; bool matched = false;
for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i!=nodeTree.end(); i++){ for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i!=nodeTree.end(); ++i){
if(!cmp_func((*i)->name, *ci)){ if(!cmp_func((*i)->name, *ci)){
matched = true; matched = true;
break; break;
@@ -567,7 +567,7 @@ const DOTCONFDocumentNode * DOTCONFDocument::findNode(const char * nodeName, con
if( i != nodeTree.end() ) ++i; if( i != nodeTree.end() ) ++i;
} }
for(; i!=nodeTree.end(); i++){ for(; i!=nodeTree.end(); ++i){
if((*i)->parentNode != parentNode){ if((*i)->parentNode != parentNode){
continue; continue;
+3 -3
View File
@@ -22,7 +22,7 @@ AsyncDNSMemPool::AsyncDNSMemPool(size_t _defaultSize):
AsyncDNSMemPool::~AsyncDNSMemPool() AsyncDNSMemPool::~AsyncDNSMemPool()
{ {
for(size_t i = 0; i<chunksCount; i++){ for(size_t i = 0; i<chunksCount; ++i){
delete chunks[i]; delete chunks[i];
} }
::free(chunks); ::free(chunks);
@@ -53,7 +53,7 @@ void AsyncDNSMemPool::addNewChunk(size_t size)
void * AsyncDNSMemPool::alloc(size_t size) void * AsyncDNSMemPool::alloc(size_t size)
{ {
PoolChunk * chunk = NULL; PoolChunk * chunk = NULL;
for(size_t i = 0; i<chunksCount; i++){ for(size_t i = 0; i<chunksCount; ++i){
chunk = chunks[i]; chunk = chunks[i];
if((chunk->size - chunk->pos) >= size){ if((chunk->size - chunk->pos) >= size){
chunk->pos += size; chunk->pos += size;
@@ -71,7 +71,7 @@ void AsyncDNSMemPool::free()
size_t psz = 0; size_t psz = 0;
++poolUsageCounter; ++poolUsageCounter;
for(size_t i = 0; i<chunksCount; i++){ for(size_t i = 0; i<chunksCount; ++i){
pu += chunks[i]->pos; pu += chunks[i]->pos;
psz += chunks[i]->size; psz += chunks[i]->size;
chunks[i]->pos = 0; chunks[i]->pos = 0;