Skip to main content

Bug Tracker

Side navigation

#5476 closed enhancement (fixed)

Opened November 09, 2009 04:21PM UTC

Closed December 06, 2010 10:05PM UTC

Prevent get(-1) to create a new jQuery object

Reported by: rkatic Owned by: jitter
Priority: high Milestone: 1.5
Component: core Version: 1.4.4
Keywords: get, slice Cc:
Blocked by: Blocking:
Description

Instead of

( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );

you will write

( num < 0 ? slice.call(this, num)[ 0 ] : this[ num ] );

or even better (for me)

( num < 0 ? this[ this.length - num ] : this[ num ] );
Attachments (0)
Change History (7)

Changed November 09, 2009 04:45PM UTC by rkatic comment:1

oops, wrong sign

( num < 0 ? this[ this.length + num ] : this[ num ] );

Changed November 19, 2010 06:43AM UTC by snover comment:2

owner: → rkatic
status: newpending

Sorry, what is the issue here? What use case is there for this?

Changed November 19, 2010 06:58AM UTC by rkatic comment:3

status: pendingnew

.get(Number) returns a single element. It is unnecessary and relatively expensive to create a new jQuery object calling .slice() only to get a single value.

Changed November 19, 2010 12:00PM UTC by jitter comment:4

_comment0: [https://github.com/jquery/jquery/pull/102 pull request] \ \ [http://jsperf.com/tetete2 performance comparision] \ \ [http://www.jsfiddle.net/jitter/4kKFJ/ test case] which shows `get()` new vs old1290381570500074
milestone: → 1.5
priority: majorhigh
status: newopen
version: 1.3.21.4.4

pull request

performance test improvement >90%

test case which shows get() new vs old

Changed November 21, 2010 10:10PM UTC by snover comment:5

owner: rkaticjitter
status: openassigned

Changed December 06, 2010 10:05PM UTC by john comment:6

milestone: 1.51.4.5
resolution: → fixed
status: assignedclosed

Landed.

Changed January 14, 2011 10:20PM UTC by jitter comment:7

milestone: 1.4.51.5

Move fixed tickets to appropriate milestone