[Webkit-unassigned] [Bug 38572] [WTFURL] Add core URL parser
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri May 7 08:33:08 PDT 2010
https://bugs.webkit.org/show_bug.cgi?id=38572
--- Comment #25 from Alexey Proskuryakov <ap at webkit.org> 2010-05-07 08:33:07 PST ---
> I'm not sure how to break out of the loop without a goto, and I'm not sure
> having a goto improve readability. :)
for (int i = path.begin(); i < pathEnd; i++) {
switch (spec[i]) {
case '?':
// Only match the query string if it precedes the reference
fragment
// and when we haven't found one already.
- if (refSeparator < 0 && querySeparator < 0)
+ if (querySeparator < 0)
querySeparator = i;
break;
case '#':
// Record the first # sign only.
- if (refSeparator < 0)
- refSeparator = i;
+ refSeparator = i;
+ i = pathEnd; // Break out of the loop.
break;
default:
break;
}
}
Another alternative is to avoid using switch, which is rather pointless for two
cases - then break would work.
> What name do you suggest? I've changed it to "specLength" because that's the
> name of the parameter that's always supplied. (Note that although "end" is a
> tempting name, it's actually end+1.)
I don't see it changed in trimURL(), which is the function I was commenting
about.
It's a common idiom to use "end" for a position just after the end, see e.g.
Vector::end(), or even the code quoted above that uses pathEnd.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list