Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use const reference in SymbolTable lookup to avoid possible copy

  • Loading branch information...
commit 29f2f9fd069373c2b8a0b12b3019bf27526aab79 1 parent 1fc13f2
@nazgob nazgob authored
Showing with 5 additions and 5 deletions.
  1. +3 −3 vm/symboltable.cpp
  2. +2 −2 vm/symboltable.hpp
View
6 vm/symboltable.cpp
@@ -96,11 +96,11 @@ namespace rubinius {
return 0;
}
- Symbol* SymbolTable::lookup(SharedState* shared, std::string str) {
+ Symbol* SymbolTable::lookup(SharedState* shared, const std::string& str) {
return lookup(str.data(), str.size(), shared->hash_seed);
}
- Symbol* SymbolTable::lookup(STATE, std::string str) {
+ Symbol* SymbolTable::lookup(STATE, const std::string& str) {
return lookup(str.data(), str.size(), state->hash_seed());
}
@@ -125,7 +125,7 @@ namespace rubinius {
symbols[hash] = v;
} else {
SymbolIds& v = entry->second;
- for(SymbolIds::iterator i = v.begin(); i != v.end(); ++i) {
+ for(SymbolIds::const_iterator i = v.begin(); i != v.end(); ++i) {
std::string& s = strings[*i];
if(!strncmp(s.data(), str, length)) return Symbol::from_index(*i);
View
4 vm/symboltable.hpp
@@ -66,8 +66,8 @@ namespace rubinius {
return bytes_used_;
}
- Symbol* lookup(SharedState* shared, std::string str);
- Symbol* lookup(STATE, std::string str);
+ Symbol* lookup(SharedState* shared, const std::string& str);
+ Symbol* lookup(STATE, const std::string& str);
Symbol* lookup(STATE, const char* str, size_t length);
Symbol* lookup(STATE, String* str);
String* lookup_string(STATE, const Symbol* sym);
Please sign in to comment.
Something went wrong with that request. Please try again.