Ticket #44 (closed enhancement: fixed)

Opened 7 years ago

Last modified 7 years ago

Avoid two extra assignments in config.macros.tagging.handler

Reported by: UdoBorkowski Owned by: JeremyRuston
Priority: minor Milestone:
Component: core Version:
Severity: low Keywords:
Cc:

Description

Currently (in TW 2.0.11) the function config.macros.tagging.handler starts like this

config.macros.tagging.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
	var theList = createTiddlyElement(place,"ul");
	var title = "";
	if(tiddler instanceof Tiddler)
		title = tiddler.title;
	if(params[0])
		title = params[0];

Depending on how the title is defined a value is assigned to the variable "title" up to three times, even though only one assignment is necessary. The following refactoring avoids this:

config.macros.tagging.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
	var theList = createTiddlyElement(place,"ul");
	var title = params[0] ? params[0] :
		tiddler instanceof Tiddler ? tiddler.title : "";

Change History

Changed 7 years ago by JeremyRuston

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

Fixed in changeset:249

Note: See TracTickets for help on using tickets.