From 4c49e4e2b5ac9bac33a78519fa18ed93f7e121ff Mon Sep 17 00:00:00 2001 From: "bmeurer@chromium.org" Date: Mon, 28 Oct 2013 09:39:00 +0000 Subject: [PATCH] Cast const char * to const uint8_t *, which removed a unnecessary version of InternalStringToDouble template. Code size (android arm build for d8): old d8: 17,479,047 bytes new d8: 17,445,492 bytes Total code size saved: 33,555 bytes R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/36903002 Patch from Bangfu Tao . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17409 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/conversions.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/conversions.cc b/src/conversions.cc index fd0f9ee4d8..5f1219eea9 100644 --- a/src/conversions.cc +++ b/src/conversions.cc @@ -46,8 +46,11 @@ namespace internal { double StringToDouble(UnicodeCache* unicode_cache, const char* str, int flags, double empty_string_val) { - const char* end = str + StrLength(str); - return InternalStringToDouble(unicode_cache, str, end, flags, + // We cast to const uint8_t* here to avoid instantiating the + // InternalStringToDouble() template for const char* as well. + const uint8_t* start = reinterpret_cast(str); + const uint8_t* end = start + StrLength(str); + return InternalStringToDouble(unicode_cache, start, end, flags, empty_string_val); } @@ -56,11 +59,15 @@ double StringToDouble(UnicodeCache* unicode_cache, Vector str, int flags, double empty_string_val) { - const char* end = str.start() + str.length(); - return InternalStringToDouble(unicode_cache, str.start(), end, flags, + // We cast to const uint8_t* here to avoid instantiating the + // InternalStringToDouble() template for const char* as well. + const uint8_t* start = reinterpret_cast(str.start()); + const uint8_t* end = start + str.length(); + return InternalStringToDouble(unicode_cache, start, end, flags, empty_string_val); } + double StringToDouble(UnicodeCache* unicode_cache, Vector str, int flags,