Ignore:
Timestamp:
2010-05-28 07:39:52 (2 years ago)
Author:
kpoole
Message:

Episode 5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Classes/config_cache.cpp

    r23 r26  
    536536char *loadStringTable = NULL; 
    537537unsigned long totalStringSize=0; 
     538std::map<std::string, int> stringTableHelper; 
    538539 
    539540void cacheFreeStringTable(void) 
    540541{ 
    541542    stringTable.clear(); 
     543    stringTableHelper.clear(); 
    542544    stringOffsets.clear(); 
    543545    if (loadStringTable) 
     
    555557     
    556558    // check if vector contains element 
    557     std::vector<std::string>::iterator it; 
    558     it = std::find(stringTable.begin(), stringTable.end(), str); 
    559     if (it == stringTable.end()) 
     559    //std::vector<std::string>::iterator it; 
     560    //it = std::find(stringTable.begin(), stringTable.end(), str); 
     561    std::map<std::string, int>::iterator fnd; 
     562    fnd = stringTableHelper.lower_bound(str); 
     563     
     564    if (fnd != stringTableHelper.end() && !(stringTableHelper.key_comp()(str, fnd->first))) 
     565    { 
     566        //pos = it - stringTable.begin(); 
     567        pos = fnd->second; 
     568    } 
     569    else 
    560570    { 
    561571        stringTable.push_back(str); 
     
    563573        pos = stringTable.size() - 1; 
    564574        totalStringSize += str.size(); 
    565     } 
    566     else 
    567     { 
    568         pos = it - stringTable.begin(); 
     575        stringTableHelper.insert(fnd, std::make_pair<std::string, int>(str, pos)); 
    569576    } 
    570577     
Note: See TracChangeset for help on using the changeset viewer.