Bug Tracker

Opened 8 years ago

Closed 6 years ago

#5476 closed enhancement (fixed)

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 ] );

Change History (7)

comment:1 Changed 8 years ago by rkatic

oops, wrong sign

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

comment:2 Changed 7 years ago by snover

Owner: set to rkatic
Status: newpending

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

comment:3 Changed 7 years ago by rkatic

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.

comment:4 Changed 7 years ago by jitter

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

Last edited 7 years ago by jitter (previous) (diff)

comment:5 Changed 7 years ago by snover

Owner: changed from rkatic to jitter
Status: openassigned

comment:6 Changed 6 years ago by john

Milestone: 1.51.4.5
Resolution: fixed
Status: assignedclosed

Landed.

comment:7 Changed 6 years ago by jitter

Milestone: 1.4.51.5

Move fixed tickets to appropriate milestone

Note: See TracTickets for help on using tickets.