mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 11:45:37 +00:00
Bug 1472031 - Implement a SourceUnits::remaining() function exposing how many code units are left. r=arai
--HG-- extra : rebase_source : a0e1e6add04478f6dda4407943772683f77fad24
This commit is contained in:
parent
4ec8af2179
commit
75148cb5d5
@ -946,6 +946,11 @@ class SourceUnits
|
||||
return ptr >= limit_;
|
||||
}
|
||||
|
||||
size_t remaining() const {
|
||||
MOZ_ASSERT(ptr, "can't get a count of remaining code units if poisoned");
|
||||
return mozilla::PointerRangeSize(ptr, limit_);
|
||||
}
|
||||
|
||||
size_t startOffset() const {
|
||||
return startOffset_;
|
||||
}
|
||||
@ -980,7 +985,7 @@ class SourceUnits
|
||||
|
||||
bool peekCodeUnits(uint8_t n, CharT* out) const {
|
||||
MOZ_ASSERT(ptr, "shouldn't peek into poisoned SourceUnits");
|
||||
if (n > mozilla::PointerRangeSize(ptr, limit_))
|
||||
if (n > remaining())
|
||||
return false;
|
||||
|
||||
std::copy_n(ptr, n, out);
|
||||
@ -989,7 +994,7 @@ class SourceUnits
|
||||
|
||||
void skipCodeUnits(uint32_t n) {
|
||||
MOZ_ASSERT(ptr, "shouldn't use poisoned SourceUnits");
|
||||
MOZ_ASSERT(n <= mozilla::PointerRangeSize(ptr, limit_),
|
||||
MOZ_ASSERT(n <= remaining(),
|
||||
"shouldn't skip beyond end of SourceUnits");
|
||||
ptr += n;
|
||||
}
|
||||
@ -997,7 +1002,7 @@ class SourceUnits
|
||||
void unskipCodeUnits(uint32_t n) {
|
||||
MOZ_ASSERT(ptr, "shouldn't use poisoned SourceUnits");
|
||||
MOZ_ASSERT(n <= mozilla::PointerRangeSize(base_, ptr),
|
||||
"shouldn't skip beyond start of SourceUnits");
|
||||
"shouldn't unskip beyond start of SourceUnits");
|
||||
ptr -= n;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user