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

Unified Diff: src/runtime.cc

Issue 15162002: Avoid convertion to double when it is not needed. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index d3baaa440cf7c49a64d1d3a5baeefa0eac4e1162..7529192e2427f205c47e867707150fd2224137df 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -857,9 +857,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) {
ASSERT(byte_length % elementSize == 0);
size_t length = byte_length / elementSize;
- Handle<Object> length_obj =
- isolate->factory()->NewNumber(static_cast<double>(length));
- holder->set_length(*length_obj);
+ if (Smi::IsValid(static_cast<intptr_t>(length))) {
rossberg 2013/05/14 14:00:45 I think this should be refactored into a function
+ holder->set_length(Smi::FromIntptr(length));
+ } else {
+ Handle<Object> length_obj=
+ isolate->factory()->NewNumber(static_cast<double>(length));
+ holder->set_length(*length_obj);
+ }
+
Handle<ExternalArray> elements =
isolate->factory()->NewExternalArray(
static_cast<int>(length), arrayType,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698