OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } else { | 237 } else { |
238 return %StringReplaceRegExpWithString(subject, | 238 return %StringReplaceRegExpWithString(subject, |
239 search, | 239 search, |
240 TO_STRING_INLINE(replace), | 240 TO_STRING_INLINE(replace), |
241 lastMatchInfo); | 241 lastMatchInfo); |
242 } | 242 } |
243 } | 243 } |
244 | 244 |
245 // Convert the search argument to a string and search for it. | 245 // Convert the search argument to a string and search for it. |
246 search = TO_STRING_INLINE(search); | 246 search = TO_STRING_INLINE(search); |
| 247 if (search.length == 1 && |
| 248 IS_STRING(replace) && |
| 249 %StringIndexOf(replace, '$', 0) < 0) { |
| 250 return %StringReplaceOneCharWithString(subject, search, replace); |
| 251 } |
247 var start = %StringIndexOf(subject, search, 0); | 252 var start = %StringIndexOf(subject, search, 0); |
248 if (start < 0) return subject; | 253 if (start < 0) return subject; |
249 var end = start + search.length; | 254 var end = start + search.length; |
250 | 255 |
251 var builder = new ReplaceResultBuilder(subject); | 256 var builder = new ReplaceResultBuilder(subject); |
252 // prefix | 257 // prefix |
253 builder.addSpecialSlice(0, start); | 258 builder.addSpecialSlice(0, start); |
254 | 259 |
255 // Compute the string to replace with. | 260 // Compute the string to replace with. |
256 if (IS_SPEC_FUNCTION(replace)) { | 261 if (IS_SPEC_FUNCTION(replace)) { |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 "fixed", StringFixed, | 1004 "fixed", StringFixed, |
1000 "italics", StringItalics, | 1005 "italics", StringItalics, |
1001 "small", StringSmall, | 1006 "small", StringSmall, |
1002 "strike", StringStrike, | 1007 "strike", StringStrike, |
1003 "sub", StringSub, | 1008 "sub", StringSub, |
1004 "sup", StringSup | 1009 "sup", StringSup |
1005 )); | 1010 )); |
1006 } | 1011 } |
1007 | 1012 |
1008 SetUpString(); | 1013 SetUpString(); |
OLD | NEW |