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

Side by Side Diff: src/conversions.cc

Issue 9408: Removed some unsafe uses of StringShape.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler.cc ('k') | src/factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 115
116 static inline bool SubStringEquals(const char* str, 116 static inline bool SubStringEquals(const char* str,
117 int index, 117 int index,
118 const char* other) { 118 const char* other) {
119 return strncmp(str + index, other, strlen(other)) != 0; 119 return strncmp(str + index, other, strlen(other)) != 0;
120 } 120 }
121 121
122 122
123 static inline bool SubStringEquals(String* str, int index, const char* other) { 123 static inline bool SubStringEquals(String* str, int index, const char* other) {
124 StringShape shape(str);
125 HandleScope scope; 124 HandleScope scope;
126 int str_length = str->length(shape); 125 int str_length = str->length();
127 int other_length = strlen(other); 126 int other_length = strlen(other);
128 int end = index + other_length < str_length ? 127 int end = index + other_length < str_length ?
129 index + other_length : 128 index + other_length :
130 str_length; 129 str_length;
131 Handle<String> slice = 130 Handle<String> slice =
132 Factory::NewStringSlice(Handle<String>(str), shape, index, end); 131 Factory::NewStringSlice(Handle<String>(str), index, end);
133 return slice->IsEqualTo(Vector<const char>(other, other_length)); 132 return slice->IsEqualTo(Vector<const char>(other, other_length));
134 } 133 }
135 134
136 135
137 // Check if a string should be parsed as an octal number. The string 136 // Check if a string should be parsed as an octal number. The string
138 // can be either a char* or a String*. 137 // can be either a char* or a String*.
139 template<class S> 138 template<class S>
140 static bool ShouldParseOctal(S* s, int i) { 139 static bool ShouldParseOctal(S* s, int i) {
141 int index = i; 140 int index = i;
142 int len = GetLength(s); 141 int len = GetLength(s);
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 // Allocate result and fill in the parts. 701 // Allocate result and fill in the parts.
703 StringBuilder builder(result_size + 1); 702 StringBuilder builder(result_size + 1);
704 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size); 703 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size);
705 if (decimal_pos > 0) builder.AddCharacter('.'); 704 if (decimal_pos > 0) builder.AddCharacter('.');
706 builder.AddSubstring(decimal_buffer, decimal_pos); 705 builder.AddSubstring(decimal_buffer, decimal_pos);
707 return builder.Finalize(); 706 return builder.Finalize();
708 } 707 }
709 708
710 709
711 } } // namespace v8::internal 710 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698