Bug 1286911. r=wchen.

MozReview-Commit-ID: hzAu0jKAxt
This commit is contained in:
Henri Sivonen
2016-09-27 13:47:53 +03:00
parent 8f7fd3f8a5
commit 4eb7f7145d
5 changed files with 39 additions and 24 deletions

View File

@@ -817,6 +817,8 @@ public class Tokenizer implements Locator {
}
@Inline private void appendCharRefBuf(char c) {
// CPPONLY: assert charRefBufLen < charRefBuf.length:
// CPPONLY: "RELEASE: Attempted to overrun charRefBuf!";
charRefBuf[charRefBufLen++] = c;
}
@@ -850,7 +852,13 @@ public class Tokenizer implements Locator {
* @param c
* the UTF-16 code unit to append
*/
private void appendStrBuf(char c) {
@Inline private void appendStrBuf(char c) {
// CPPONLY: assert strBufLen < strBuf.length: "Previous buffer length insufficient.";
// CPPONLY: if (strBufLen == strBuf.length) {
// CPPONLY: if (!EnsureBufferSpace(1)) {
// CPPONLY: assert false: "RELEASE: Unable to recover from buffer reallocation failure";
// CPPONLY: } // TODO: Add telemetry when outer if fires but inner does not
// CPPONLY: }
strBuf[strBufLen++] = c;
}
@@ -951,14 +959,15 @@ public class Tokenizer implements Locator {
}
private void appendStrBuf(@NoLength char[] buffer, int offset, int length) {
int reqLen = strBufLen + length;
if (strBuf.length < reqLen) {
char[] newBuf = new char[reqLen + (reqLen >> 1)];
System.arraycopy(strBuf, 0, newBuf, 0, strBuf.length);
strBuf = newBuf;
}
int newLen = strBufLen + length;
// CPPONLY: assert newLen <= strBuf.length: "Previous buffer length insufficient.";
// CPPONLY: if (strBuf.length < newLen) {
// CPPONLY: if (!EnsureBufferSpace(length)) {
// CPPONLY: assert false: "RELEASE: Unable to recover from buffer reallocation failure";
// CPPONLY: } // TODO: Add telemetry when outer if fires but inner does not
// CPPONLY: }
System.arraycopy(buffer, offset, strBuf, strBufLen, length);
strBufLen = reqLen;
strBufLen = newLen;
}
/**