Closed Bug 248768 Opened 20 years ago Closed 20 years ago

parser code for IMAP and addrbook: stroken_r: pull end-of-string checks out of char-delimiter loop

Categories

(MailNews Core :: Networking: IMAP, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: engel, Assigned: engel)

References

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040622
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040622

In stroken_r(), a string is tokenized until the end of this string is reached.  
Currently, the check for this end-of-string condition is carried out somewhat ne
sted within the loop over the list of token delimiters.  This check should be p
ulled out of the loop to increase readability of the code.  Performance can be s
lightly increased.

stroken_r is defined in
  mailnews/imap/src/nsIMAPGenericParser.cpp
  mailnews/addrbook/src/nsDirPrefs.cpp

Patch forthcoming.

Reproducible: Always
Steps to Reproduce:
Attached patch proposed patchSplinter Review
Refactored stroken_r, behavior of stroken_r remains unchanged.

Note that this patch should not impair performance.  With the new code and for
each input, the number of branches is never larger than in the original code.
Attachment #151785 - Flags: superreview?(mscott)
Attachment #151785 - Flags: review?(bienvenu)
Comment on attachment 151785 [details] [diff] [review]
proposed patch

looks OK - I'm going to try running with the patch. Also, I'm going to fix the
braces to match the rest of the imap code, and remove the tabs...
Attachment #151785 - Flags: review?(bienvenu) → review+
Thank you for your review!  I only removed the tabs from the lines which I have
changed such that the patch remains short and clear.  Cleaning up the tabs now
sounds good.
Punting bug into confirmed state, since David is looking at the patch...
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Linux → All
Hardware: PC → All
Status: NEW → ASSIGNED
Assignee: bienvenu → Hans-A.Engel
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
Attachment #151785 - Flags: superreview?(mscott) → superreview?(neil.parkwaycc.co.uk)
Comment on attachment 151785 [details] [diff] [review]
proposed patch

Although I would have thought this could have been further optimized since the
call sites are virtually identical.
Attachment #151785 - Flags: superreview?(neil.parkwaycc.co.uk) → superreview+
filed Bug 253794 on unifying these functions, and possibly replacing them with
nsCRT::strtok_r
Fix landed by timeless:

07/31/2004 21:02
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Product: MailNews → Core
Verified FIXED using LXR for code inspection:

1.43	neil%parkwaycc.co.uk	2004-12-07 16:02	 	Bug 273080 Remove double assignment
fNextToken = nsIMAPGenericParser::GetNextToken() p=Hans-A.Engel@unibas.ch
r=bienvenu sr=dmose
Status: RESOLVED → VERIFIED
Blocks: 313038
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: