get rid of tmp variable, we dont need it

pull/490/head
Rich-Harris 9 years ago
parent 950f2ce2fd
commit 2e7a429684

@ -154,9 +154,4 @@ export default class Block {
} }
`; `;
} }
tmp () {
if ( !this._tmp ) this._tmp = this.getUniqueName( 'tmp' );
return this._tmp;
}
} }

@ -81,8 +81,7 @@ export default function visitAttribute ( generator, block, state, node, attribut
block.builders.create.addLine( updater ); block.builders.create.addLine( updater );
block.builders.update.addBlock( deindent` block.builders.update.addBlock( deindent`
if ( ( ${block.tmp()} = ${value} ) !== ${last} ) { if ( ${last} !== ( ${last} = ${value} ) ) {
${last} = ${block.tmp()};
${updater} ${updater}
} }
` ); ` );

@ -9,8 +9,8 @@ export default function visitMustacheTag ( generator, block, state, node ) {
block.addElement( name, `${generator.helper( 'createText' )}( last_${name} )`, state.parentNode, true ); block.addElement( name, `${generator.helper( 'createText' )}( last_${name} )`, state.parentNode, true );
block.builders.update.addBlock( deindent` block.builders.update.addBlock( deindent`
if ( ( ${block.tmp()} = ${snippet} ) !== last_${name} ) { if ( last_${name} !== ( last_${name} = ${snippet} ) ) {
${name}.data = last_${name} = ${block.tmp()}; ${name}.data = last_${name};
} }
` ); ` );
} }

@ -26,8 +26,7 @@ export default function visitRawMustacheTag ( generator, block, state, node ) {
} }
block.builders.update.addBlock( deindent` block.builders.update.addBlock( deindent`
if ( ( ${block.tmp()} = ${snippet} ) !== last_${name} ) { if ( last_${name} !== ( last_${name} = ${snippet} ) ) {
last_${name} = ${block.tmp()};
${detachStatement} ${detachStatement}
${mountStatement} ${mountStatement}
} }

@ -75,18 +75,15 @@ function create_each_block ( root, each_block_value, comment, comment_index, com
}, },
update: function ( changed, root, each_block_value, comment, comment_index ) { update: function ( changed, root, each_block_value, comment, comment_index ) {
var tmp; if ( last_text !== ( last_text = comment.author ) ) {
text.data = last_text;
if ( ( tmp = comment.author ) !== last_text ) {
text.data = last_text = tmp;
} }
if ( ( tmp = root.elapsed(comment.time, root.time) ) !== last_text_2 ) { if ( last_text_2 !== ( last_text_2 = root.elapsed(comment.time, root.time) ) ) {
text_2.data = last_text_2 = tmp; text_2.data = last_text_2;
} }
if ( ( tmp = comment.html ) !== last_raw ) { if ( last_raw !== ( last_raw = comment.html ) ) {
last_raw = tmp;
detachBetween( raw_before, raw_after ); detachBetween( raw_before, raw_after );
raw_before.insertAdjacentHTML( 'afterend', last_raw ); raw_before.insertAdjacentHTML( 'afterend', last_raw );
} }

Loading…
Cancel
Save