kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Optimise $tw.utils.parseStringArray()
On my machine, the following test performed on the prerelease improves from 40ms to 8ms with this patch: ``` var a = $tw.utils.stringifyList($tw.wiki.allTitles());console.time();$tw.utils.p arseStringArray(a);console.timeEnd() ```print-window-tiddler
rodzic
daf703b67f
commit
75b501f681
|
@ -271,14 +271,15 @@ $tw.utils.stringifyList = function(value) {
|
|||
$tw.utils.parseStringArray = function(value) {
|
||||
if(typeof value === "string") {
|
||||
var memberRegExp = /(?:^|[^\S\xA0])(?:\[\[(.*?)\]\])(?=[^\S\xA0]|$)|([\S\xA0]+)/mg,
|
||||
results = [],
|
||||
results = [], names = {},
|
||||
match;
|
||||
do {
|
||||
match = memberRegExp.exec(value);
|
||||
if(match) {
|
||||
var item = match[1] || match[2];
|
||||
if(item !== undefined && results.indexOf(item) === -1) {
|
||||
if(item !== undefined && !$tw.utils.hop(names,item)) {
|
||||
results.push(item);
|
||||
names[item] = true;
|
||||
}
|
||||
}
|
||||
} while(match);
|
||||
|
|
Ładowanie…
Reference in New Issue