Shouldn't use FindCharInSet when searching for one char

RESOLVED FIXED in mozilla1.2beta

Status

MailNews Core
MIME
--
trivial
RESOLVED FIXED
17 years ago
10 years ago

People

(Reporter: Daniel Bratell, Assigned: Daniel Bratell)

Tracking

({perf})

Trunk
mozilla1.2beta

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

1.37 KB, patch
(not reading, please use seth@sspitzer.org instead)
: review+
Alec Flett
: superreview+
Details | Diff | Splinter Review
(Assignee)

Description

17 years ago
FindChar is (much) more efficient than FindCharInSet when searching for just 
one char. Still there are several misusers in the tree.

/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp, line 406 -- end = 
contentType.FindCharInSet("\"", start );

/intl/strres/src/nsAcceptLang.cpp, line 114 -- PRInt32 dash = 
lc_tmp.FindCharInSet("-");

/intl/strres/src/nsAcceptLang.cpp, line 169 -- PRInt32 dash = 
acceptLang.FindCharInSet("-");

/intl/strres/src/nsStringBundle.cpp, line 446 -- PRInt32 dash = 
lc_name.FindCharInSet("-");

/xpcom/tests/windows/nsStringTest.h, line 391 -- pos = T2.FindCharInSet("A");

/xpcom/tests/windows/nsStringTest.h, line 394 -- pos=T2.RFindCharInSet("A",2);

/content/html/document/src/nsHTMLDocument.cpp, line 470 -- end = 
contentType.FindCharInSet("\"", start);

/content/xml/document/src/nsXMLDocument.cpp, line 409 -- end = 
contentType.FindCharInSet("\"", start );

/xpfe/components/search/src/nsInternetSearchService.cpp, line 4988 -- 
quoteEndOffset = resultItem.FindCharInSet(">", quoteStartOffset);

/xpfe/components/search/src/nsInternetSearchService.cpp, line 5123 -- PRInt32 
protocolOffset = site.FindCharInSet(":", 0);

/xpfe/components/search/src/nsInternetSearchService.cpp, line 5131 -- PRInt32 
slashOffset = site.FindCharInSet("/", 0);

/xpfe/components/search/src/nsInternetSearchService.cpp, line 5173 -- PRInt32 
anchorEnd = resultItem.FindCharInSet(">", quoteEndOffset);

/mailnews/base/util/nsMsgMailNewsUrl.cpp, line 604 -- PRInt32 pos = 
mAttachmentFileName.RFindCharInSet(".");

/mailnews/mime/src/mimedrft.cpp, line 1768 -- PRInt32 pos = 
contentType.FindCharInSet(";");

/mailnews/mime/src/mimemoz2.cpp, line 244 -- PRInt32 pos = 
contentType.FindCharInSet(";");

If I get the optimizations into FindCharInSet that is in another bug, that 
function will be even more optimized to handle sets larger than one char.

Updated

17 years ago
Keywords: perf

Updated

17 years ago
Component: Browser-General → Tracking
QA Contact: doronr → chofmann
(Assignee)

Comment 1

15 years ago
There was only one offending module left. Someone must have cleaned this up
(alecf?) since this bug was filed. Will attach patch. 

alefc and sspitzer, can you r= and sr= it?
Status: NEW → ASSIGNED
Component: Tracking → MIME
Product: Browser → MailNews
Target Milestone: --- → mozilla1.2beta
(Assignee)

Comment 2

15 years ago
Created attachment 100134 [details] [diff] [review]
Replacing FindCharInSet with FindChar

Replacing 2 occurrances of FindCharInSet with FindChar because FindChar is
simpler and faster and it's confusing to use FindCharInSet when searching for a
single character.

Comment 3

15 years ago
Comment on attachment 100134 [details] [diff] [review]
Replacing FindCharInSet with FindChar

yeah, I think I may have cleaned some of the others up.
sr=alecf
Attachment #100134 - Flags: superreview+
(Assignee)

Updated

15 years ago
Attachment #100134 - Flags: review?(sspitzer)
Attachment #100134 - Flags: review?(sspitzer) → review+
(Assignee)

Comment 4

15 years ago
Fix checked in.
Status: ASSIGNED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.