@@ -982,12 +982,9 @@ private void emitOrAppendCharRefBuf(int returnState) throws SAXException {
982982 * @param c
983983 * the UTF-16 code unit to append
984984 */
985- private void appendStrBuf (char c ) {
986- // CPPONLY: assert strBufLen < strBuf.length: "Previous buffer length insufficient.";
985+ @ Inline private void appendStrBuf (char c ) {
987986 // CPPONLY: if (strBufLen == strBuf.length) {
988- // CPPONLY: if (!EnsureBufferSpace(1)) {
989- // CPPONLY: assert false: "RELEASE: Unable to recover from buffer reallocation failure";
990- // CPPONLY: } // TODO: Add telemetry when outer if fires but inner does not
987+ // CPPONLY: EnsureBufferSpaceShouldNeverHappen(1);
991988 // CPPONLY: }
992989 strBuf [strBufLen ++] = c ;
993990 }
@@ -1094,13 +1091,12 @@ private void maybeAppendSpaceToBogusComment() throws SAXException {
10941091 // ]NOCPP]
10951092 }
10961093
1097- private void appendStrBuf (@ NoLength char [] buffer , int offset , int length ) throws SAXException {
1098- int newLen = Portability .checkedAdd (strBufLen , length );
1099- // CPPONLY: assert newLen <= strBuf.length: "Previous buffer length insufficient.";
1094+ @ Inline private void appendStrBuf (@ NoLength char [] buffer , int offset , int length ) throws SAXException {
1095+ // Years of crash stats have shown that the this addition doesn't overflow, as it logically
1096+ // shouldn't.
1097+ int newLen = strBufLen + length ;
11001098 // CPPONLY: if (strBuf.length < newLen) {
1101- // CPPONLY: if (!EnsureBufferSpace(length)) {
1102- // CPPONLY: assert false: "RELEASE: Unable to recover from buffer reallocation failure";
1103- // CPPONLY: } // TODO: Add telemetry when outer if fires but inner does not
1099+ // CPPONLY: EnsureBufferSpaceShouldNeverHappen(length);
11041100 // CPPONLY: }
11051101 System .arraycopy (buffer , offset , strBuf , strBufLen , length );
11061102 strBufLen = newLen ;
0 commit comments