Bug Tracker

Opened 12 years ago

Closed 12 years ago

#1318 closed enhancement (fixed)

save some bytes in grep

Reported by: rformato Owned by:
Priority: minor Milestone: 1.2.4
Component: core Version: 1.1.2
Keywords: Cc:
Blocked by: Blocking:

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 (1)

grep.patch (459 bytes) - added by rformato 12 years ago.
Patch

Download all attachments as: .zip

Change History (5)

Changed 12 years ago by rformato

Attachment: grep.patch added

Patch

comment:1 Changed 12 years ago by flesler

Milestone: 1.1.31.2.4
Resolution: fixed
Status: newclosed

Nice one, applied at [5558].

comment:2 Changed 12 years ago by Markus.Staab

if (!a != !b)

you could save another few bytes with

a != b

ne two negations are not neccesarry..

comment:3 Changed 12 years ago by Markus.Staab

Resolution: fixed
Status: closedreopened

comment:4 Changed 12 years ago by flesler

Resolution: fixed
Status: reopenedclosed

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.