Bug Tracker

Modify

Ticket #4407 (closed enhancement: worksforme)

Opened 4 years ago

Last modified 2 years ago

Empty selectbox

Reported by: Jorik Owned by:
Priority: major Milestone: 1.3.2
Component: core Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

The empty() method on a selectbox is _much_ slower then selectbox.options.length = 0; Maybe it is nice to check if the element is a selectbox, and then use the options.length way to empty the selectbox.

Attachments

Untitled-1.html Download (1.9 KB) - added by jerone 4 years ago.
testcase

Change History

comment:1 Changed 4 years ago by jerone

I tested whats faster; the build-in jQuery technick of a while loop and your suggestion of length=0 Aldo your suggestion is faster then the while loop, it's not the while loop that slows it down; it's the expando management that is the 'problem'.

Changed 4 years ago by jerone

testcase

comment:2 Changed 4 years ago by jerone

My test results in FF:

  • test1: 73ms
  • test2: 1ms
  • test3: 4ms

comment:3 Changed 4 years ago by dmethvin

  • Component changed from unfilled to core

comment:4 Changed 3 years ago by dmethvin

  • Keywords needsreview added
  • Status changed from new to open

We still need to clean off the data attributes. I can't get the test case to work though.

comment:5 Changed 2 years ago by dmethvin

  • Status changed from open to closed
  • Resolution set to worksforme

The differences don't seem that large to me; I even increased the number of options. For cases where someone is updating large numbers selects at a high frequency and is willing to risk the memory leaks, they can set options.length=0.

 http://jsfiddle.net/dmethvin/pm7Y2/

comment:6 Changed 2 years ago by dmethvin

  • Keywords needsreview removed

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.