Closed Bug 542655 Opened 16 years ago Closed 16 years ago

String.indexOf and String.lastIndexOf can be optimized

Categories

(Tamarin Graveyard :: Virtual Machine, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: stejohns, Unassigned)

Details

Attachments

(1 file)

Attached patch PatchSplinter Review
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.
Attachment #423874 - Attachment is patch: true
Attachment #423874 - Attachment mime type: application/octet-stream → text/plain
Attachment #423874 - Flags: review?(edwsmith)
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+
patlen<=0 should be filtered out by the caller in all cases, but I'll doublecheck and add assertions to that effect
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: