Refactor filter compilation into its own source file

This commit is contained in:
Jeremy Ruston 2023-11-08 09:29:57 +00:00
parent 6997c61bc1
commit 5d20e983b6
4 changed files with 28 additions and 10 deletions

View File

@ -246,7 +246,7 @@ exports.compileFilter = function(filterString) {
};
}
// Get the filter function
var fnFilter = this.optimiseFilter && this.optimiseFilter(filterString);
var fnFilter = this.optimiseFilter && this.optimiseFilter(filterString,filterParseTree);
if(!fnFilter) {
fnFilter = this.compileFilterToJavaScript(filterParseTree);
}

View File

@ -9,4 +9,5 @@ tags: $:/tags/RawMarkupWikified
{{$:/plugins/tiddlywiki/sqlite3store/sql-functions.js}}
{{$:/plugins/tiddlywiki/sqlite3store/test-sql-functions.js}}
{{$:/plugins/tiddlywiki/sqlite3store/sql-wiki-store.js}}
{{$:/plugins/tiddlywiki/sqlite3store/sql-filter-compiler.js}}
`</script>`

View File

@ -0,0 +1,26 @@
/*\
title: $:/plugins/tiddlywiki/sqlite3store/sql-filter-compiler.js
type: application/javascript
A sqlite3 implementation of a wiki store object
This file is spliced into the HTML file to be executed before the boot kernel has been loaded.
\*/
(function() {
/*
If possible, return a filter evaluation function with the signature (source,widget) that executes the provided filter parse tree
*/
$tw.Wiki.prototype.optimiseFilter = function(filterString,filterParseTree) {
// switch($tw.utils.trim(filterString)) {
// case "[all[shadows+tiddlers]prefix[$:/language/Docs/Types/]get[name]length[]maxall[]]":
// return [this.sqlFunctions.sqlQuickFilterAllShadowsTiddlersPrefixDocTypeMaxLength()];
// break;
// }
return undefined;
};
})();
//# sourceURL=$:/plugins/tiddlywiki/sqlite3store/sql-filter-compiler.js

View File

@ -337,15 +337,6 @@ console.log("Added indexer",name)
this.clearAllCaches();
};
this.optimiseFilter = function(filterString) {
// switch($tw.utils.trim(filterString)) {
// case "[all[shadows+tiddlers]prefix[$:/language/Docs/Types/]get[name]length[]maxall[]]":
// return [this.sqlFunctions.sqlQuickFilterAllShadowsTiddlersPrefixDocTypeMaxLength()];
// break;
// }
return undefined;
};
function TagSubIndexer(indexer,iteratorMethod) {
this.indexer = indexer;
this.iteratorMethod = iteratorMethod;