Performance re toc-nav (tiddlytools)

I was experimenting with toc-nav (from tiddlytools.com). I liked the general idea and appearance, but I noticed that my computer fan was always running (which is my unscientific way of telling if something has a performance problem). I was navigating through an extensive list of 157 items, and each step takes about 2 seconds.

I’m thinking the problem is that it is having to constantly recalculate the flat list. Not a problem I imagine if you only have 20 or so items.

As an experiment, I tweaked the code to make my own version that uses a stored list for navigation. Now I could navigate each step in less than a second.

I’m thinking a version that includes a tiny “update” button might help performance. The button would store the flat list for the current navigation somewhere. The user would only use it after they’ve made changes to the source material.

Just throwing it out there for consideration.

Thanks!

For larger trees, using <<toc-nav>> may add a noticeable delay while navigating between tree tiddlers. This is because it calculates the <<toc-list>> output each time a tiddler is rendered. To address this, <<toc-nav>> already includes support for improving performance by using a “pre-computed” toc-items list of tiddler titles.

The last two lines of the macro are:

<$list filter="[<toc-items>match[]]" emptyMessage=<<show>> variable=none>
<$wikify name=toc-items text="<$macrocall $name=toc-list here=<<__here__>> max=<<__max__>> exclude=<<__exclude__>> field=<<__field__>>/>"><<show>>

Thus, when toc-items is already defined, it bypasses the costly $wikify widget, and just calls <<show>> to display the navigation controls.

To calculate and save the list of tiddlers, first create a tiddler (e.g., “Set MyTOCList”) containing:

<$button>Set MyTOCList
<$wikify name=toc-items text="<<toc-list roottag>>">
<$action-setfield $tiddler="MyTOCList" list=<<toc-items>>/>
</$wikify>
</$button>

and press this button to compute and save the list of tiddlers. Then, in the tiddler(s) where you invoke <<toc-nav>>, use this syntax:

<$let toc-items={{MyTOCList!!list}}><<toc-nav>></$let>

Let me know how it goes…

enjoy,
-e

Maybe I’m using it wrong? I put it in a viewtemplate. Maybe there is some other scenario where you somehow stay on the same tiddler? Because otherwise it seems like every time you navigate to a new tiddler, the variable will be empty and it will have to re-calculate.

In any event, when I navigated using a pre-calculated (stored in a list field) value, navigation occurred twice as fast as when using the default toc-nav.

Thank you!

If you’ve used

<$let toc-items={{MyTOCList!!list}}><<toc-nav>></$let>

and correctly populated the list field of the MyTOCList tiddler, then the <<toc-items>> variable should not be empty.

Note: in this line

<$wikify name=toc-items text="<<toc-list roottag>>">

roottag is just a placeholder. You need to change it to use YOUR roottag value!

-e