diff options
author | Jentsch <d.jentsch@fu-berlin.de> | 2013-10-23 12:59:45 +0200 |
---|---|---|
committer | Jentsch <d.jentsch@fu-berlin.de> | 2013-10-23 12:59:45 +0200 |
commit | ce5cfd228a2fece13fe7aeabaa8297d976f31e37 (patch) | |
tree | 34007a7bcf0a5938da7348cf950ba11e181739e7 /src | |
parent | 54707cb45018170e31eb188a9a694ab9b0728f71 (diff) | |
download | scala-ce5cfd228a2fece13fe7aeabaa8297d976f31e37.tar.gz scala-ce5cfd228a2fece13fe7aeabaa8297d976f31e37.tar.bz2 scala-ce5cfd228a2fece13fe7aeabaa8297d976f31e37.zip |
Prevent useless filter operation in docs
Diffstat (limited to 'src')
-rw-r--r-- | src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js index 96689ae701..c201b324e7 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js +++ b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js @@ -383,51 +383,56 @@ function compilePattern(query) { // Filters all focused templates and packages. This function should be made less-blocking. // @param query The string of the query function textFilter() { - scheduler.clear("filter"); - - $('#tpl').html(''); - var query = $("#textfilter input").attr("value") || ''; var queryRegExp = compilePattern(query); - var index = 0; + if ((typeof textFilter.lastQuery === "undefined") || (textFilter.lastQuery !== query)) { + + textFilter.lastQuery = query; - var searchLoop = function () { - var packages = Index.keys(Index.PACKAGES).sort(); + scheduler.clear("filter"); - while (packages[index]) { - var pack = packages[index]; - var children = Index.PACKAGES[pack]; - index++; + $('#tpl').html(''); - if (focusFilterState) { - if (pack == focusFilterState || - pack.indexOf(focusFilterState + '.') == 0) { - ; - } else { - continue; + var index = 0; + + var searchLoop = function () { + var packages = Index.keys(Index.PACKAGES).sort(); + + while (packages[index]) { + var pack = packages[index]; + var children = Index.PACKAGES[pack]; + index++; + + if (focusFilterState) { + if (pack == focusFilterState || + pack.indexOf(focusFilterState + '.') == 0) { + ; + } else { + continue; + } } - } - var matched = $.grep(children, function (child, i) { - return queryRegExp.test(child.name); - }); + var matched = $.grep(children, function (child, i) { + return queryRegExp.test(child.name); + }); - if (matched.length > 0) { - $('#tpl').append(Index.createPackageTree(pack, matched, - focusFilterState)); - scheduler.add('filter', searchLoop); - return; + if (matched.length > 0) { + $('#tpl').append(Index.createPackageTree(pack, matched, + focusFilterState)); + scheduler.add('filter', searchLoop); + return; + } } - } - $('#tpl a.packfocus').click(function () { - focusFilter($(this).parent().parent()); - }); - configureHideFilter(); - }; + $('#tpl a.packfocus').click(function () { + focusFilter($(this).parent().parent()); + }); + configureHideFilter(); + }; - scheduler.add('filter', searchLoop); + scheduler.add('filter', searchLoop); + } } /* Configures the hide tool by adding the hide link to all packages. */ |