String.indexOf and String.lastIndexOf can be optimized

RESOLVED FIXED

Status

RESOLVED FIXED
9 years ago
9 years ago

People

(Reporter: stejohns, Unassigned)

Tracking

Details

Attachments

(1 attachment)

(Reporter)

Description

9 years ago
Created attachment 423874 [details] [diff] [review]
Patch

Enclosed patch generates substantially better code for VC2008 (but roughly similar code for gcc 4.x). On Windows this moves the needle substantiall for benchmarks of these two methods (moving from slower-than-FP10 to faster-than-FP10).

Basically, cache pattern[0] and preflight the pattern-matching before proceeding.
(Reporter)

Updated

9 years ago
Attachment #423874 - Attachment is patch: true
Attachment #423874 - Attachment mime type: application/octet-stream → text/plain
Attachment #423874 - Flags: review?(edwsmith)

Comment 1

9 years ago
Comment on attachment 423874 [details] [diff] [review]
Patch

Looks fine as long as we don't crash when patlen <= 0 by reading pat[0] before we checking the loop condition (j < patlen)
Attachment #423874 - Flags: review?(edwsmith) → review+
(Reporter)

Comment 2

9 years ago
patlen<=0 should be filtered out by the caller in all cases, but I'll doublecheck and add assertions to that effect
(Reporter)

Comment 3

9 years ago
http://hg.mozilla.org/tamarin-redux/rev/1be67eeeb784
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.