Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <4493946.nSsM8AgQI3@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Thu, 23 May 2013 17:53 +0200 User-Agent: KNode/4.10.2 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. MIME-Version: 1.0 Lines: 54 NNTP-Posting-Date: 23 May 2013 17:53:00 CEST NNTP-Posting-Host: d86d8774.newsspool4.arcor-online.net X-Trace: DXC=2eS_o3nJoF=T2Rfi6]gf>eVeX3`a I'm working with some people who write code and minimises it. As ab > afterthought, I unminimise some of it and worked my way through it. > > One thing I found was that the minimiser had converted all instances of > true to !0. > > When I reported it no one thought it an issue as both true and !0 are > truthy. Should they be concerned? They should reconsider their approach as they are exchanging a minor increase in loading performance against a probably larger reduction of runtime performance, adding an operation (“!”) where there does not have to be one, just for the sake of two octets less per occurrence (“!0” vs. “true”). They should ask themselves instead why there were so many occurrences of ”true” in the code in the first place. If I wrote a minimizer, *that* is where I would look first. For example, if (x == true) and if (true == x) can be minimized to the equivalent, shorter, more efficient if (x) This is easy to find and replace with regular expressions: /* if (x) if (y) z; */ "if (x == true) if (true == y) z;" .replace(/([^=])\s*==\s*true\b|\btrue\s*==\s*([^=])/g, "$1$2"); or /* if (x) if (y) z; */ "if (x == true) if (true == y) z;" .replace(/([^=])\s*==\s*true\b|\btrue\s*==(?!=)\s*/g, "$1"); or if the minimizer was Perl or PCRE-based, you could use negative lookbehind. (Exceptions for String and RegExp literals not included.) Same for type-converting comparisons with “false” and negative type- converting comparisons with “true” and “false”. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.