Ticket #873 (closed enhancement: fixed)

Opened 20 months ago

Last modified 10 months ago

Tags macro does not respect excludeLists

Reported by: FND Owned by: FND
Priority: minor Milestone: 2.6
Component: core Version:
Severity: low Keywords:
Cc:

Description

The Tags macro does not respect the excludeLists tag; tags tagged with excludeLists still show up in the list.

Change History

Changed 20 months ago by FND

related: #515

Changed 17 months ago by FND

  • owner changed from JeremyRuston to FND
  • status changed from new to assigned

Changed 17 months ago by FND

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in changeset:9465.

Changed 14 months ago by FND

  • priority changed from minor to major
  • status changed from closed to reopened
  • resolution fixed deleted
  • milestone changed from 2.5.1 to 2.5.3

This fix was accidentally reverted in changeset:9493.

Changed 14 months ago by MartinBudden

  • status changed from reopened to closed
  • resolution set to fixed

Fixed in changeset:10053

Changed 13 months ago by EricShulman

  • priority changed from major to minor
  • status changed from closed to reopened
  • type changed from defect to enhancement
  • resolution fixed deleted
  • milestone changed from 2.5.3 to 2.5.4

The current fix DOES work... however, because it invokes store.getTiddler() within the 'for each tag' loop, it changes the performance profile from O(n) to O(n2), which might add a notable amount of overhead, especially in documents with many tiddlers that have extensive tagging.

Here's the current code (as of TW253):

	for(var t=0; t<tiddler.tags.length; t++) {
		var tag = store.getTiddler(tiddler.tags[t]); 
		if(!tag || !tag.tags.contains("excludeLists")) { 
			...
		}
	}

a more efficient approach would involve peforming a single linear lookup to retrieve the list of all excludeLists-tagged titles *before* the loop and then, within the loop simply check to see if a given tag is in that pre-fetched list, like this:

	var excluded=[];
	store.forEachTiddler(function(title,tiddler) {
		if (tiddler.isTagged("excludeLists") excluded.push(title);
	});
	for(var t=0; t<tiddler.tags.length; t++) {
		if (!excluded.contains(tiddler.tags[t]) {
			...
		}
	}

Changed 13 months ago by MartinBudden

Tiddlers are stored in a hashmap, so store.getTiddler() is O(1), not O(n), so the performance of the loop is still O(n).

Changed 13 months ago by EricShulman

The O(1) load for getTiddler() is true for an unmodified TW core. However, plugins (e.g. IncludePlugin?) can hijack getTiddler() in order to provided access to extended 'multi-store' tiddler data, so the overhead for getTiddler() *might* be O(n) or worse, depending upon exactly what plugins are installed, resulting in O(n2) for the whole tags macro loop. The suggested change should result in O(n), regardless of any plugin-enhanced extensions to the core.

Still, this might not produce that much of a performance improvement... but it's worth considering...

Changed 10 months ago by MartinBudden

  • status changed from reopened to closed
  • resolution set to fixed

Performance not an issue in the core case. Hijackers of getTiddler need to be aware of any performance issues they may introduce in this and other areas.

Note: See TracTickets for help on using tickets.