mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1305422 - part 5 - simplify Is8bit; r=baku
The implementation of Is8bit, with its multiply-nested loops, dates from the time when string iterators could be fragmented into multiple pieces. We no longer have such iterators, so we can write Is8bit much more straightforwardly, with the single loop you would expect.
This commit is contained in:
parent
92e64e1b8c
commit
70d6d5515f
@ -792,23 +792,12 @@ Is8bit(const nsAString& aString)
|
||||
{
|
||||
static const char16_t EIGHT_BIT = char16_t(~0x00FF);
|
||||
|
||||
nsAString::const_iterator done_reading;
|
||||
aString.EndReading(done_reading);
|
||||
|
||||
// for each chunk of |aString|...
|
||||
uint32_t fragmentLength = 0;
|
||||
nsAString::const_iterator iter;
|
||||
for (aString.BeginReading(iter); iter != done_reading;
|
||||
iter.advance(int32_t(fragmentLength))) {
|
||||
fragmentLength = uint32_t(iter.size_forward());
|
||||
const char16_t* c = iter.get();
|
||||
const char16_t* fragmentEnd = c + fragmentLength;
|
||||
|
||||
// for each character in this chunk...
|
||||
while (c < fragmentEnd) {
|
||||
if (*c++ & EIGHT_BIT) {
|
||||
return false;
|
||||
}
|
||||
for (nsAString::const_char_iterator start = aString.BeginReading(),
|
||||
end = aString.EndReading();
|
||||
start != end;
|
||||
++start) {
|
||||
if (*start & EIGHT_BIT) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user