Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index f629970ff28209a568124a23ef07bed9194cbe3c..46f314e48b5e38dc0caf01c90d34d65b3e1b7f67 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -3163,25 +3163,31 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) { |
int position = -1; |
- if (pat->IsAsciiRepresentation()) { |
- Vector<const char> pat_vector = pat->ToAsciiVector(); |
- if (sub->IsAsciiRepresentation()) { |
- position = StringMatchBackwards(sub->ToAsciiVector(), |
+ String* seq_sub = *sub; |
+ // Extract flattened substrings of cons strings before determining asciiness. |
Vitaly Repeshko
2011/08/22 13:37:46
nit: Move the comment one line above.
|
+ if (seq_sub->IsConsString()) seq_sub = ConsString::cast(seq_sub)->first(); |
+ String* seq_pat = *pat; |
+ if (seq_pat->IsConsString()) seq_pat = ConsString::cast(seq_pat)->first(); |
+ |
+ if (seq_pat->IsAsciiRepresentation()) { |
+ Vector<const char> pat_vector = seq_pat->ToAsciiVector(); |
+ if (seq_sub->IsAsciiRepresentation()) { |
+ position = StringMatchBackwards(seq_sub->ToAsciiVector(), |
pat_vector, |
start_index); |
} else { |
- position = StringMatchBackwards(sub->ToUC16Vector(), |
+ position = StringMatchBackwards(seq_sub->ToUC16Vector(), |
pat_vector, |
start_index); |
} |
} else { |
- Vector<const uc16> pat_vector = pat->ToUC16Vector(); |
- if (sub->IsAsciiRepresentation()) { |
- position = StringMatchBackwards(sub->ToAsciiVector(), |
+ Vector<const uc16> pat_vector = seq_pat->ToUC16Vector(); |
+ if (seq_sub->IsAsciiRepresentation()) { |
+ position = StringMatchBackwards(seq_sub->ToAsciiVector(), |
pat_vector, |
start_index); |
} else { |
- position = StringMatchBackwards(sub->ToUC16Vector(), |
+ position = StringMatchBackwards(seq_sub->ToUC16Vector(), |
pat_vector, |
start_index); |
} |