Changeset 921


Ignore:
Timestamp:
Dec 1, 2009, 4:55:52 AM (11 years ago)
Author:
Peter Johansson
Message:

minor speed improvement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Colours.cc

    r919 r921  
    6666                           unsigned char& g, unsigned char& b)
    6767  {
    68     std::map<std::string,std::vector<colour>::iterator>::const_iterator i;
    69     if ((i=author_map_.find(label)) == author_map_.end()) {
     68    std::map<std::string,std::vector<colour>::iterator>::iterator i;
     69    i = author_map_.lower_bound(label);
     70    if (i==author_map_.end() || i->first != label) {
    7071      // no colour defined for label, set colour for label
    71       author_map_[label]=next_colour_++;
     72      i = author_map_.insert(i, std::make_pair(label, next_colour_++));
    7273      if (next_colour_==colour_map_.end())
    7374        // end of colour map reach, start over
    7475        next_colour_=colour_map_.begin();
    7576    }
    76     r=author_map_[label]->r;
    77     g=author_map_[label]->g;
    78     b=author_map_[label]->b;
     77    r = i->second->r;
     78    g = i->second->g;
     79    b = i->second->b;
    7980  }
    8081
Note: See TracChangeset for help on using the changeset viewer.