summaryrefslogtreecommitdiff
path: root/deps/v8/src/string.js
diff options
context:
space:
mode:
authorRyan <ry@tinyclouds.org>2009-06-08 18:34:06 +0200
committerRyan <ry@tinyclouds.org>2009-06-08 18:34:06 +0200
commit696f02455792b368249bf9b013dde637b5ec31fd (patch)
tree95b2dbd6c2537df9df52f6627aac36fcf05f6a7a /deps/v8/src/string.js
parentf6a7fe26574defaa807a13248102ebe0f23270af (diff)
downloadnode-new-696f02455792b368249bf9b013dde637b5ec31fd.tar.gz
Upgrade to v8 1.2.7
Diffstat (limited to 'deps/v8/src/string.js')
-rw-r--r--deps/v8/src/string.js28
1 files changed, 17 insertions, 11 deletions
diff --git a/deps/v8/src/string.js b/deps/v8/src/string.js
index 0bcabc943b..df1f393e01 100644
--- a/deps/v8/src/string.js
+++ b/deps/v8/src/string.js
@@ -120,20 +120,26 @@ function StringIndexOf(searchString /* position */) { // length == 1
// ECMA-262 section 15.5.4.8
function StringLastIndexOf(searchString /* position */) { // length == 1
var sub = ToString(this);
+ var subLength = sub.length;
var pat = ToString(searchString);
- var index = (%_ArgumentsLength() > 1)
- ? ToNumber(%_Arguments(1) /* position */)
- : $NaN;
- var firstIndex;
- if ($isNaN(index)) {
- firstIndex = sub.length - pat.length;
- } else {
- firstIndex = TO_INTEGER(index);
- if (firstIndex + pat.length > sub.length) {
- firstIndex = sub.length - pat.length;
+ var patLength = pat.length;
+ var index = subLength - patLength;
+ if (%_ArgumentsLength() > 1) {
+ var position = ToNumber(%_Arguments(1));
+ if (!$isNaN(position)) {
+ position = TO_INTEGER(position);
+ if (position < 0) {
+ position = 0;
+ }
+ if (position + patLength < subLength) {
+ index = position
+ }
}
}
- return %StringLastIndexOf(sub, pat, firstIndex);
+ if (index < 0) {
+ return -1;
+ }
+ return %StringLastIndexOf(sub, pat, index);
}