jQuery: The Write Less, Do More JavaScript Library

Ticket #1318 (closed enhancement: fixed)

Opened 1 year ago

Last modified 3 months ago

save some bytes in grep

Reported by: rformato Assigned to: anonymous
Type: enhancement Priority: minor
Milestone: 1.2.4 Component: core
Version: 1.1.2 Keywords:
Cc: Needs: Review

Description

Hi,

we can save save bytes in grep replacing the line if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )

with

if ( !inv != !fn(elems[i],i) )

Attachments

grep.patch (459 bytes) - added by rformato 1 year ago.
Patch

Change History

Changed 1 year ago by rformato

Patch

Changed 3 months ago by flesler

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from 1.1.3 to 1.2.4

Nice one, applied at [5558].

Changed 3 months ago by Markus.Staab

if (!a != !b)

you could save another few bytes with

a != b

ne two negations are not neccesarry..

Changed 3 months ago by Markus.Staab

  • status changed from closed to reopened
  • resolution deleted

Changed 3 months ago by flesler

  • status changed from reopened to closed
  • resolution set to fixed

Wrong, a could be null, and b, false.. or a similar case. Casting both to bolean ensures equality.

Please reopen if you disagree.

Note: See TracTickets for help on using tickets.