# A Question of Performance Accessing Current Tiddler Variable

It seems when accessing the current tiddler variable, the performance is in the following order

1. the highest: <currentTiddler>
2. then the all[current]
3. the lowest is[current]

Is this true in all situations?

### References

1 Like

I think this is true according to arguments others in the know have put in the past, but performance is most likely influenced in many ways by what you then do with it.

• If you consider that <currentTiddler> is using an already identified value and the next two examples need to identify what the current tiddler is, one may need to step back and ask how was <currentTiddler> set in the first place.
• Of course the currentTiddler, and for that matter storyTiddler are set when rendering a tiddler in the story.
• I use all[current] not is[current] but I have always felt it should logically be the other wat around.

Do you ever experience a local or in the worst case a more global performance issue?

• Ideally if you are going to ask tiddlywiki to do a lot of work, then it is wise to keep it inside a tiddler that needs to be opened to get that result, and does not remain open or active on an ongoing basis especially when making ongoing changes, that cause it to refresh.
• For large lists you can limit the output and have pages or flexible limits, would you really look through a list of 100 items? But keep in mind to filter and sort then limit the output, it still first needs to iterate the full list.
• I expect for many a performance hit comes when less than optimal methods are used to identify relevant titles and the display of the result.
• Reuse is a great way to reduce performance demands, save a list in a variable and enlist it, if the list is needed many times rather than regenerating the list from “first principals again”.
• Place filters in the order that reduces the number of items most quickly, and use those in indexed filter operators

With performance if it is the wiki load time, there are other solutions.

What about [{!!title}] ?

• On reflection I expect this is similar to using <currentTiddler> as I mentioned above since it does assume the current tiddler is set.
• I personally write most of my macros and transclusions templates etc… to use the current tiddler variable by default thus they can be used in the current tiddler or within a list field that iterates the current tiddler.
• In macros that may be used against a one off named tiddler (not too common) I use a code pattern that allows the tiddler name to be overwritten;
\define mymacro(tiddlername)
<$set name=currentTiddler value="""$tiddlername$""" emptyValue=<<currentTiddler>> > </$set>
\end

<<mymacro>> <!-- uses current tiddler -->
<<mymacro "tiddlername">> <!-- uses tiddlername -->

• I am not concerned with performance in occasional use macros.

A point to be made with performance issues is I have found them to be rare and prefer instead to code for readability, reuse and ease of use, especially when returning.

• I would advise if you redesign a solution for performance reasons to make sure you annotate it as such, eg <!-- filter order and nested lists optimised for performance --> lest you return to make a minor change and damage all your prior optimisation work.
1 Like