question: private byte skipTagBackward ( ) { int initialCharIndex = charIndex ; while ( charIndex > 0 ) { lastChar = text . charAt ( -- charIndex ) ; if ( lastChar == '<' ) { return Character . DIRECTIONALITY_WHITESPACE ; } if ( lastChar == '>' ) { break ; } if ( lastChar == '"' || lastChar == '\'' ) { char quote = lastChar ; while ( charIndex > 0 && ( lastChar = text . charAt ( -- charIndex ) ) != quote ) { } } } charIndex = initialCharIndex ; lastChar = '>' ; return Character . DIRECTIONALITY_OTHER_NEUTRALS ; }
target:  Advances charIndex backward through an HTML tag (after the closing &gt; has already been read) and returns Character.DIRECTIONALITY_WHITESPACE. If there is no matching &lt;, does not change charIndex and returns Character.DIRECTIONALITY_OTHER_NEUTRALS (for the &gt; that hadn't been part of a tag after all). Nevertheless, the running time for calling skipTagBackward() in a loop remains linear in the size of the text, even for a text like "&gt;&gt;&gt;&gt;", because skipTagBackward() also stops looking for a matching &lt; when it encounters another &gt;.