Changeset 126 for trunk/src/xmlmodel.c


Ignore:
Timestamp:
May 2, 2008, 5:45:26 PM (11 years ago)
Author:
lindanl
Message:

Use NameID vs. name string as key for element, attribute, ... maps.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/xmlmodel.c

    r102 r126  
    1111
    1212void Model_Info::SimpleEntity(char * entity_Name, char * replText) {
    13                 int entityID = GlobalGEntityTable[entity_Name];
     13                int entity_NameID = GlobalNameTable[entity_Name];
     14                if (entity_NameID == 0) {
     15                        GlobalNameTable[entity_Name] = ++(globalNameCount);
     16                        entity_NameID = globalNameCount;
     17                }
     18                int entityID = GlobalGEntityTable[entity_NameID];
    1419                if(entityID==0){       
    1520                        GEntity_info * this_info = new GEntity_info;
    16                         GlobalGEntityTable[entity_Name]=++(globalGEntityCount);
     21                        GlobalGEntityTable[entity_NameID]=++(globalGEntityCount);
    1722                        entityID = globalGEntityCount;
    1823               
     
    3237        globalElementCount = 0;
    3338        globalAttributeCount = 0;
     39        globalNameCount = 0;
    3440        SimpleEntity("lt", "<");
    3541        SimpleEntity("gt", ">");
     
    114120                BOM_units = B;
    115121 }
    116 int Model_Info::getOrInsertGlobalElement(unsigned char * elem_name, int lgth) {
    117         int elemID;
    118         char *s = new char[lgth+1];
    119         memcpy(s, elem_name, lgth);
    120         s[lgth] = '\0';
    121         elemID = GlobalElementTable[s];
     122int Model_Info::getOrInsertGlobalElement(int elem_nameID) {
     123        int elemID =  GlobalElementTable[elem_nameID];
    122124        if(elemID==0){ 
    123                 GlobalElementTable[s]=++(globalElementCount);
     125                GlobalElementTable[elem_nameID]=++(globalElementCount);
    124126                elemID = globalElementCount;
    125127               
     
    129131}
    130132
    131 int Model_Info::getOrInsertGlobalAttName(unsigned char * att_name, int lgth){
    132        
    133         char *s = new char[lgth+1];
    134         memcpy(s, att_name, lgth);
    135         s[lgth] = '\0';
    136        
    137         int attID = GlobalAttributeTable[s];
     133int Model_Info::getOrInsertGlobalAttName(int att_nameID){
     134               
     135        int attID = GlobalAttributeTable[att_nameID];
    138136        if(attID==0){   
    139                 GlobalAttributeTable[s]=++(globalAttributeCount);
     137                GlobalAttributeTable[att_nameID]=++(globalAttributeCount);
    140138                attID = globalAttributeCount;
    141139        }
Note: See TracChangeset for help on using the changeset viewer.