Closed Bug 103343 Opened 23 years ago Closed 23 years ago

Check for IsEmpty before more expensive value check

Categories

(Toolkit :: Form Manager, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: timeless, Unassigned)

References

()

Details

(Keywords: perf)

Attachments

(1 file, 1 obsolete file)

while popping around the jprof profiling for bug 77073 It seems to me that we can save some time in the not too rare case where there is no input type.
Comment on attachment 52249 [details] [diff] [review] reorder IsEmpty before expensive string comparison ()s in wrong place. sorry
Attachment #52249 - Attachment is obsolete: true
Attachment #52249 - Flags: needs-work+
Actually... there is a futher speedup here. How about: + (type.IsEmpty() || + (Compare(type, NS_LITERAL_STRING("text"), + nsCaseInsensitiveStringComparator()) == 0))) { That avoids the conversion as well.
Keywords: perf
r=morse for Zbarsky's modification to patch cc'ing alecf for sr
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.6
Blocks: 77073
Attachment #52250 - Flags: review+
sr=alecf on that second iteration...
:-)
Assignee: morse → timeless
Status: ASSIGNED → NEW
fix checked in
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
I think it would've been wiser to determine how often situation A happens, and how often situation B happens. If A happens more often than B, testing for situation B before testing for situation A will only slow the A case down, no matter how much cheaper B is than A. (A == Compare, B == IsEmpty).
Assignee: timeless → nobody
Product: Core → Toolkit
QA Contact: tpreston → form.manager
Target Milestone: mozilla0.9.6 → ---
Version: Trunk → unspecified
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: