lib/demangler/prefix-tree.js
// Replace all matches (longest match first) in a line.
Replace all matches (longest match first) in a line.
Replace all matches ( longest match first ) in a line .
replaceAll(line) {
        let result = '';
        let index = 0;
        while (index < line.length) {
            const lineBit = line.substr(index);
            const [oldValue, newValue] = this.findLongestMatch(lineBit);
            if (oldValue) {
                result += newValue;
                index += oldValue.length;
            } else {
                result += line[index];
                index++;
            }
        }
        return result;
    }
replaceAll ( line ) { let result = '' ; let index = 0 ; while ( index < line . length ) { const lineBit = line . substr ( index ) ; const [ oldValue , newValue ] = this . findLongestMatch ( lineBit ) ; if ( oldValue ) { result += newValue ; index += oldValue . length ; } else { result += line [ index ] ; index ++ ; } } return result ; }
Replace all matches (longest match first) in a line.
Replace all matches ( longest match first ) in a line .
// Loop over each possible replacement point in the line. // Use a binary search to find the replacements (allowing a prefix match). If we couldn't find a match, skip // on, else use the replacement, and skip by that amount. // We found a replacement. // No match; output the unmatched character, and keep looking.