Refactor Heap::SymbolMapForString to use switch/case.
Review URL: http://codereview.chromium.org/8683001 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10055 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
2055f4195e
commit
c2514c8c8e
42
src/heap.cc
42
src/heap.cc
@ -3975,40 +3975,22 @@ Map* Heap::SymbolMapForString(String* string) {
|
||||
if (InNewSpace(string)) return NULL;
|
||||
|
||||
// Find the corresponding symbol map for strings.
|
||||
Map* map = string->map();
|
||||
if (map == ascii_string_map()) {
|
||||
return ascii_symbol_map();
|
||||
}
|
||||
if (map == string_map()) {
|
||||
return symbol_map();
|
||||
}
|
||||
if (map == cons_string_map()) {
|
||||
return cons_symbol_map();
|
||||
}
|
||||
if (map == cons_ascii_string_map()) {
|
||||
return cons_ascii_symbol_map();
|
||||
}
|
||||
if (map == external_string_map()) {
|
||||
return external_symbol_map();
|
||||
}
|
||||
if (map == external_ascii_string_map()) {
|
||||
return external_ascii_symbol_map();
|
||||
}
|
||||
if (map == external_string_with_ascii_data_map()) {
|
||||
switch (string->map()->instance_type()) {
|
||||
case STRING_TYPE: return symbol_map();
|
||||
case ASCII_STRING_TYPE: return ascii_symbol_map();
|
||||
case CONS_STRING_TYPE: return cons_symbol_map();
|
||||
case CONS_ASCII_STRING_TYPE: return cons_ascii_symbol_map();
|
||||
case EXTERNAL_STRING_TYPE: return external_symbol_map();
|
||||
case EXTERNAL_ASCII_STRING_TYPE: return external_ascii_symbol_map();
|
||||
case EXTERNAL_STRING_WITH_ASCII_DATA_TYPE:
|
||||
return external_symbol_with_ascii_data_map();
|
||||
}
|
||||
if (map == short_external_string_map()) {
|
||||
return short_external_symbol_map();
|
||||
}
|
||||
if (map == short_external_ascii_string_map()) {
|
||||
case SHORT_EXTERNAL_STRING_TYPE: return short_external_symbol_map();
|
||||
case SHORT_EXTERNAL_ASCII_STRING_TYPE:
|
||||
return short_external_ascii_symbol_map();
|
||||
}
|
||||
if (map == short_external_string_with_ascii_data_map()) {
|
||||
case SHORT_EXTERNAL_STRING_WITH_ASCII_DATA_TYPE:
|
||||
return short_external_symbol_with_ascii_data_map();
|
||||
default: return NULL; // No match found.
|
||||
}
|
||||
|
||||
// No match found.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user