Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1154)

Unified Diff: src/runtime.cc

Issue 409007: Some optimizations for packer.js. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/objects-inl.h ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ }
}
« src/objects-inl.h ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698