Closed
Bug 755480
Opened 12 years ago
Closed 12 years ago
Optimize WordSplitState::FindSpecialWord some more
Categories
(Core :: Spelling checker, defect)
Tracking
()
RESOLVED
FIXED
mozilla15
People
(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)
References
Details
(Keywords: perf)
Attachments
(3 files, 2 obsolete files)
1.42 KB,
patch
|
roc
:
review+
|
Details | Diff | Splinter Review |
1.32 KB,
patch
|
roc
:
review+
|
Details | Diff | Splinter Review |
4.69 KB,
patch
|
roc
:
review+
|
Details | Diff | Splinter Review |
Bug 753233 fixed the suckiness of this function for data: URIs, but this function still stinks perf-wise. 1. It goes through some effort to compute foundDot, and then doesn't use it! 2. When it finds a colon, it keeps on looking at every other character, when it can just look at the next character, and bail out if it detects a URL-like thingy. 3. Worst of all, for strings without @ (and : if number 2 above is fixed), this is O(nm) where n is the number of characters in the string, and m is the number of words in the string. This is because the caller hopelessly calls this over and over *even* if it returns -1, which means, "hey caller, there's nothing interesting anywhere in this string!". Point #3 just caused me to have to kill Firefox after waiting a few minutes for it to hit the event loop again. This is unacceptable!
Assignee | ||
Comment 1•12 years ago
|
||
Assignee | ||
Comment 2•12 years ago
|
||
Attachment #624172 -
Flags: review?(roc)
Attachment #624170 -
Flags: review?(roc) → review+
Attachment #624172 -
Flags: review?(roc) → review+
Assignee | ||
Comment 3•12 years ago
|
||
This is the most valuable optimization here: don't call FindSpecialWord repeatedly if it returns -1 in an iteration. Note that this is mostly reindenting existing code.
Attachment #624173 -
Flags: review?(roc)
Comment on attachment 624173 [details] [diff] [review] Part 3 Review of attachment 624173 [details] [diff] [review]: ----------------------------------------------------------------- I think this would be clearer if FindSpecialWord simply became IsSpecialWord, returning bool, and SplitDOMWord just did AdvanceThroughSeparators() first, then called IsSpecialWord, and if not a special word then did the loop.
Assignee | ||
Comment 5•12 years ago
|
||
Attachment #624173 -
Attachment is obsolete: true
Attachment #624173 -
Flags: review?(roc)
Attachment #624453 -
Flags: review?(roc)
Comment on attachment 624453 [details] [diff] [review] Part 3 Review of attachment 624453 [details] [diff] [review]: ----------------------------------------------------------------- ::: extensions/spellcheck/src/mozInlineSpellWordUtil.cpp @@ +1009,5 @@ > + > + // skip the special word > + state.mDOMWordOffset += specialWordLength; > + if (state.mDOMWordOffset + aStart >= aEnd) > + state.mCurCharClass = CHAR_CLASS_END_OF_INPUT; I think state.mDOMWordOffset is always equal to aEnd here. That means we can simplify the code. In fact, it's very confusing to have dead code here.
Assignee | ||
Comment 7•12 years ago
|
||
Attachment #624453 -
Attachment is obsolete: true
Attachment #624453 -
Flags: review?(roc)
Attachment #624742 -
Flags: review?(roc)
Comment on attachment 624742 [details] [diff] [review] Part 3 Review of attachment 624742 [details] [diff] [review]: ----------------------------------------------------------------- r+ with that fixed. ::: extensions/spellcheck/src/mozInlineSpellWordUtil.cpp @@ +1007,5 @@ > + mRealWords.AppendElement( > + RealWord(aStart + state.mDOMWordOffset, specialWordLength, false)); > + > + // skip the special word > + state.mDOMWordOffset += specialWordLength; No point in updating 'state' since it's local to this function and we're about to return!
Attachment #624742 -
Flags: review?(roc) → review+
Assignee | ||
Comment 9•12 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/44731e4787f0 https://hg.mozilla.org/integration/mozilla-inbound/rev/7b6dd63e1400 https://hg.mozilla.org/integration/mozilla-inbound/rev/942b6e232d80
Target Milestone: --- → mozilla15
Comment 10•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/44731e4787f0 https://hg.mozilla.org/mozilla-central/rev/7b6dd63e1400 https://hg.mozilla.org/mozilla-central/rev/942b6e232d80
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•