Changeset 1424


Ignore:
Timestamp:
Dec 16, 2011, 4:41:23 AM (11 years ago)
Author:
Peter Johansson
Message:

speed up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/utility.cc

    r1423 r1424  
    128128  std::string file_name(const std::string& full_path)
    129129  {
    130     std::stringstream ss(full_path);
    131     std::string name;
    132     while (getline(ss,name,'/')) {}
    133     return name;
     130    if (full_path.size()<2)
     131      return full_path;
     132    // exclude last char from search
     133    size_t pos = full_path.find_last_of('/', full_path.size()-2);
     134    if (pos==std::string::npos)
     135      return full_path;
     136    return full_path.substr(pos+1);
    134137  }
    135138
Note: See TracChangeset for help on using the changeset viewer.