https://chromiumcodereview.appspot.com/9600009/diff/18001/src/handles.cc
File src/handles.cc (right):
https://chromiumcodereview.appspot.com/9600009/diff/18001/src/handles.cc#newcode952
src/handles.cc:952: while (failure) {
On 2012/03/12 12:34:10, Erik Corry wrote:
On 2012/03/12 10:55:05, rossberg wrote:
> Nit: this seems more natural as a do-while loop.
I made it into a do-while, but it's no better (same line count, flag
must still
be declared outside the loop, still have to test the flag twice).
Just an unsolicited comment from my side: For stuff like that I usually
prefer a C/C++ emulation of Dahl's loop/while/repeat. Alas, compilers
are sometimes a bit too dumb, so an additional line has to be appended:
int Utf8Length(Handle<String> str) {
const int kRecursionBudget = 100;
while (true) {
bool failure = false, dummy;
int len = Utf8LengthHelper(
*str, 0, str->length(), false, kRecursionBudget, &failure,
&dummy);
if (!failure) return len;
FlattenString(str);
}
return 0; // Keep the compiler happy.
}
Using a "Remove Double Negative" refactoring might make this even more
clear (failure => ok).
https://chromiumcodereview.appspot.com/9600009/
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev