enamdict.js
function(callback) {
        dataIndex = {};

        var pos = 0;

        enamdictData.split("\n").forEach(function(line) {
            var parts = line.split("|");
            var cleanName = parts[0];
            var romaji = parts[1];

            if (!(cleanName in dataIndex)) {
                dataIndex[cleanName] = pos;
            }

            if (!(romaji in dataIndex)) {
                dataIndex[romaji] = pos;
            }

            // +1 for the \n
            pos += line.length + 1;
        });

        callback(null, this);
    }
function(callback) {
        dataIndex = {};

        var pos = 0;

        enamdictData.split("\n").forEach(function(line) {
            var parts = line.split("|");
            var cleanName = parts[0];
            var romaji = parts[1];

            if (!(cleanName in dataIndex)) {
                dataIndex[cleanName] = pos;
            }

            if (!(romaji in dataIndex)) {
                dataIndex[romaji] = pos;
            }

            // +1 for the \n
            pos += line.length + 1;
        });

        callback(null, this);
    }
function ( callback ) { dataIndex = { } ; var pos = 0 ; enamdictData . split ( "\n" ) . forEach ( function ( line ) { var parts = line . split ( "|" ) ; var cleanName = parts [ 0 ] ; var romaji = parts [ 1 ] ; if ( ! ( cleanName in dataIndex ) ) { dataIndex [ cleanName ] = pos ; } if ( ! ( romaji in dataIndex ) ) { dataIndex [ romaji ] = pos ; } // +1 for the \n pos += line . length + 1 ; } ) ; callback ( null , this ) ; }
Build an index to improve name lookup performance.
Build an index to improve name lookup performance .