Bug Tracker

Ticket #5476 (closed enhancement: fixed)

Opened 5 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:

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

comment:1 Changed 5 years ago by rkatic

oops, wrong sign

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

comment:2 Changed 4 years ago by snover

  • Owner set to rkatic
  • Status changed from new to pending

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

comment:3 Changed 4 years ago by rkatic

  • Status changed from pending to new

.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 4 years ago by jitter

  • Priority changed from major to high
  • Status changed from new to open
  • Version changed from 1.3.2 to 1.4.4
  • Milestone set to 1.5

 pull request

 performance test improvement >90%

 test case which shows get() new vs old

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

comment:5 Changed 4 years ago by snover

  • Owner changed from rkatic to jitter
  • Status changed from open to assigned

comment:6 Changed 4 years ago by john

  • Status changed from assigned to closed
  • Resolution set to fixed
  • Milestone changed from 1.5 to 1.4.5

Landed.

comment:7 Changed 4 years ago by jitter

  • Milestone changed from 1.4.5 to 1.5

Move fixed tickets to appropriate milestone

Note: See TracTickets for help on using tickets.