Skip to main content

Bug Tracker

Side navigation

#4311 closed enhancement (fixed)

Opened March 08, 2009 01:55PM UTC

Closed June 12, 2010 01:34PM UTC

Last modified March 14, 2012 02:09PM UTC

remove "parseInt" and speed up some div

Reported by: roviury Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

remove "parseInt":

parseInt(x,10) = (x-0)

but (x-0) is faster

the lines is the problem refer to...

1048:

(parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");

(( value -0 ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");

1267:

return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;

return elem[0] && ( jQuery.curCSS(elem[0], prop, true)-0 ) || 0;

4200-4201:

top += parseInt( computedStyle.borderTopWidth, 10) || 0,

left += parseInt( computedStyle.borderLeftWidth, 10) || 0;

top += ( computedStyle.borderTopWidth-0 ) || 0,

left += ( computedStyle.borderLeftWidth-0 ) || 0;

4205-4206:

top += parseInt( computedStyle.borderTopWidth, 10) || 0,

left += parseInt( computedStyle.borderLeftWidth, 10) || 0;

top += ( computedStyle.borderTopWidth-0 ) || 0,

left += ( computedStyle.borderLeftWidth-0 ) || 0;

4252-4253:

top += parseInt( jQuery.curCSS(body, 'marginTop', true), 10 ) || 0,

left += parseInt( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0;

top += ( jQuery.curCSS(body, 'marginTop', true)-0 ) || 0,

left += ( jQuery.curCSS(body, 'marginLeft', true)-0 ) || 0;

speed up some div:

x/100 = x * 1/100 = x * 0.01

but *0.01 faster than /100 (in most browser can speed up, even if not, it must not speed down)

ps.why is some div? the dividend must be constant!

1052:

(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':

(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) * 0.01) + '':

Attachments (1)
  • jquery-1.3.2_.js (122.0 KB) - added by roviury March 08, 2009 01:55PM UTC.

    improvement

Change History (2)

Changed March 08, 2009 02:01PM UTC by roviury comment:1

remove "parseInt":

parseInt(x,10) = (x-0)

but (x-0) is faster

the lines is the problem refer to...

1048:

(parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");

(( value -0 ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");

1267 :

return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;

return elem[0] && ( jQuery.curCSS(elem[0], prop, true)-0 ) || 0;

4200-4201 :

top += parseInt( computedStyle.borderTopWidth, 10) || 0,

left += parseInt( computedStyle.borderLeftWidth, 10) || 0;

top += ( computedStyle.borderTopWidth-0 ) || 0,

left += ( computedStyle.borderLeftWidth-0 ) || 0;

4205-4206 :

top += parseInt( computedStyle.borderTopWidth, 10) || 0,

left += parseInt( computedStyle.borderLeftWidth, 10) || 0;

top += ( computedStyle.borderTopWidth-0 ) || 0,

left += ( computedStyle.borderLeftWidth-0 ) || 0;

4252-4253 :

top += parseInt( jQuery.curCSS(body, 'marginTop', true), 10 ) || 0,

left += parseInt( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0;

top += ( jQuery.curCSS(body, 'marginTop', true)-0 ) || 0,

left += ( jQuery.curCSS(body, 'marginLeft', true)-0 ) || 0;

speed up some div :

x/100 = x * 1/100 = x * 0.01

but *0.01 faster than /100 (in most browser can speed up, even if not, it must not speed down)

ps.why is some div? the dividend must be constant!

1052 :

(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':

(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) * 0.01) + '':

Changed June 12, 2010 01:34PM UTC by dmethvin comment:2

resolution: → fixed
status: newclosed

I don't see this code in jQuery core anymore, so I'll it was fixed or rewritten.