Bug Tracker

Opened 14 years ago

Closed 13 years ago

#5476 closed enhancement (fixed)

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

Reported by: Robert Katić 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 14 years ago by Robert Katić

oops, wrong sign

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

comment:2 Changed 13 years ago by snover

Owner: set to Robert Katić
Status: newpending

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

comment:3 Changed 13 years ago by Robert Katić

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 13 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 13 years ago by jitter (previous) (diff)

comment:5 Changed 13 years ago by snover

Owner: changed from Robert Katić to jitter
Status: openassigned

comment:6 Changed 13 years ago by john

Milestone: 1.51.4.5
Resolution: fixed
Status: assignedclosed

Landed.

comment:7 Changed 12 years ago by jitter

Milestone: 1.4.51.5

Move fixed tickets to appropriate milestone

Note: See TracTickets for help on using tickets.