Closed Bug 188865 Opened 22 years ago Closed 15 years ago

Add a RFindCharInReadable function

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: Biesinger, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

Currently, there is RFindInReadable for searching strings in strings from right to left, and FindCharInReadable for finding characters in strings from the left. What's missing is RFindCharInReadable, to find the last occurence of a character (like strrchr) would come handy for bug 188586 comment 3
Summary: Add a RFindCharInReable function → Add a RFindCharInReadable function
-> scc
Assignee: jaggernaut → scc
taking
Assignee: scc → cbiesinger
OS: Linux → All
Priority: -- → P1
Hardware: PC → All
Target Milestone: --- → mozilla1.6alpha
Attached patch patch (obsolete) — Splinter Review
Status: NEW → ASSIGNED
It would be much more efficient to write this the way FindCharInReadable is written. (FWIW, see also bug 82054.) You'd need to add rfind to nsCharTraits.
Comment on attachment 133102 [details] [diff] [review] patch ok... I'll do that
Attachment #133102 - Attachment is obsolete: true
Attachment #133148 - Flags: review?(dbaron)
Comment on attachment 133148 [details] [diff] [review] implement&use nsCharTraits<...>::rfind nevermind. this hangs when given a multiple-fragment string
Attachment #133148 - Attachment is obsolete: true
Attachment #133148 - Flags: review?(dbaron) → review-
Comment on attachment 133156 [details] [diff] [review] fix hang I created two test programs to test the chartraits changes and then the RFindCharInReadable functions. I can attach them if you want
Attachment #133156 - Flags: review?(dbaron)
Do you get better code with the n-- loop control, where n is induced by s, or would you get better code if you saved the initial s in t, added n-1, and looped while s >= t? /be
Comment on attachment 133156 [details] [diff] [review] fix hang I think it would be better to have RFindCharInReadable take the first iterator as a const reference and the second iterator as a non-const reference, and modify the second when the character is found. This allows for repeated searches using the same iterators, and would also simplify the implementation. (Others may disagree, though.) Other than that, it looks fine, although I didn't look at the code in nsReadableUtils.cpp too closely.
darin's string update probably bitrotted this a lot... don't think I'll update this anytime soon, -> default owner
Assignee: cbiesinger → string
Status: ASSIGNED → NEW
Priority: P1 → --
Target Milestone: mozilla1.6alpha → ---
Assignee: string → nobody
QA Contact: scc → string
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → INCOMPLETE
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: