| 155 | } // namespace Detail |
| 156 | |
| 157 | const std::string *InternedString::internedString( const char *value ) |
| 158 | { |
| 159 | Detail::HashSet *hashSet = Detail::hashSet(); |
| 160 | Detail::Index &hashIndex = hashSet->get<0>(); |
| 161 | Detail::Mutex::scoped_lock lock( *Detail::mutex(), false ); // read-only lock |
| 162 | Detail::HashSet::const_iterator it = hashIndex.find( value ); |
| 163 | if( it!=hashIndex.end() ) |
| 164 | { |
| 165 | return &(*it); |
| 166 | } |
| 167 | else |
| 168 | { |
| 169 | lock.upgrade_to_writer(); |
| 170 | return &(*(hashSet->insert( std::string( value ) ).first ) ); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | const std::string *InternedString::internedString( const char *value, size_t length ) |
| 175 | { |