Ticket #278 (closed defect: fixed)
Story.prototype.saveTiddler sends too many notifications when extended fields are edited.
| Reported by: | UdoBorkowski | Owned by: | JeremyRuston |
|---|---|---|---|
| Priority: | critical | Milestone: | 2.2 |
| Component: | core | Version: | |
| Severity: | critical | Keywords: | |
| Cc: |
Description (last modified by UdoBorkowski) (diff)
The scenario: set up the newTiddler macro to use a template that creates about 6 extended fields in the new tiddler. The problem: saving this new tiddler takes an extremely long period of time, almost long enough to make it a deal breaker in some cases.
Looking through the code drew my attention to these lines in Story.prototype.saveTiddler :
store.saveTiddler(title,newTitle,fields.text,config.options.txtUserName,minorUpdate ? undefined : newDate,fields.tags);
for (var n in fields)
if (!TiddlyWiki.isStandardField(n))
store.setValue(newTitle,n,fields[n]);
Now correct me if I am wrong, but I believe the above code results in n+1 notifications to the store for a tiddler with n extended fields! So for a tiddler with 6 fields, we are looking at 7 notifications and possibly 7 screen redraws. Surely enough, sandwiching the setValue call between store.suspendNotifications and resumeNotifications alleviates the performance hit!
Reported by Saq in this discussion
