Index: src/runtime.cc |
=================================================================== |
--- src/runtime.cc (revision 3335) |
+++ src/runtime.cc (working copy) |
@@ -2356,16 +2356,28 @@ |
ASSERT(args.length() == 3); |
CONVERT_CHECKED(String, value, args[0]); |
- CONVERT_DOUBLE_CHECKED(from_number, args[1]); |
- CONVERT_DOUBLE_CHECKED(to_number, args[2]); |
+ Object* from = args[1]; |
+ Object* to = args[2]; |
+ if (from->IsSmi() && to->IsSmi()) { |
Søren Thygesen Gjesse
2009/11/19 21:42:57
Maybe add a comment to this fast case.
|
+ int start = Smi::cast(from)->value(); |
+ int end = Smi::cast(to)->value(); |
Søren Thygesen Gjesse
2009/11/19 21:42:57
Please move the declaration of start and end befor
|
- int start = FastD2I(from_number); |
- int end = FastD2I(to_number); |
+ RUNTIME_ASSERT(end >= start); |
+ RUNTIME_ASSERT(start >= 0); |
+ RUNTIME_ASSERT(end <= value->length()); |
+ return value->SubString(start, end); |
+ } else { |
+ CONVERT_DOUBLE_CHECKED(from_number, from); |
+ CONVERT_DOUBLE_CHECKED(to_number, to); |
- RUNTIME_ASSERT(end >= start); |
- RUNTIME_ASSERT(start >= 0); |
- RUNTIME_ASSERT(end <= value->length()); |
- return value->SubString(start, end); |
+ int start = FastD2I(from_number); |
+ int end = FastD2I(to_number); |
+ |
+ RUNTIME_ASSERT(end >= start); |
+ RUNTIME_ASSERT(start >= 0); |
+ RUNTIME_ASSERT(end <= value->length()); |
+ return value->SubString(start, end); |
+ } |
} |