On Fri, Jan 06, 2017 at 04:44:27PM +0000, Dave Mitchell wrote: > On Tue, Jan 03, 2017 at 01:22:08PM +0000, Dave Mitchell wrote: > > I've just pushed the commit shown below as davem/boolref. > > It shows that the concept is sound, but I suggest not merging into blead > > until after 5.26.0 is released: even just setting an extra private flag on > > an op may require various B-ish CPAN modules to be updated. > > > > The repeep() code in my commit is separate from similar code that puts > > rv2hv into boolean context in things like if (%h) {...}. I suspect they > > want merging into a single function. I also noticed there's a bug in the > > rv2hv stuff: if (!%h) {...} *doesn't* get optimised. > > > > I'm open to suggestions for other ops which could benefit from being > > special-cased in boolean context. > > I've since done this a different way. First I've pushed the following set > of commits to blead: > > commit bec5a1ba1ddeb36f189da30307757fead2933e93 > Merge: 12e1fa6 b243b19 > Author: David Mitchell <davem@iabyn.com> > AuthorDate: Fri Jan 6 16:28:50 2017 +0000 > Commit: David Mitchell <davem@iabyn.com> > CommitDate: Fri Jan 6 16:28:50 2017 +0000 > > [MERGE] redo boolean context > > Overhaul the stuff that flags an op as being in boolean context (currently > just padhv and rv2hv). Make the mechanism in rpeep() general, so that > other ops can be easily added in future, and add a generic testing > framework for such ops in t/perf/optree.t. > > This alters the amount on situations recognised as being in boolean > context (mainly increasing them). > > which fixes some bugs and adds a general framework for supporting boolean- > context ops. > > Then I've pushed the following branch as davem/boolref2 which I intend to > merge sometime after 5.26: > > commit a83d533d7b264b0df884decfc144af10b79c7f24 > Author: David Mitchell <davem@iabyn.com> > AuthorDate: Fri Jan 6 14:59:54 2017 +0000 > Commit: David Mitchell <davem@iabyn.com> > CommitDate: Fri Jan 6 16:32:21 2017 +0000 > > make OP_REF support boolean context > > RT #78288 > > When ref() is used in a boolean context, it's not necessary to return > the name of the package which an object is blessed into; instead a simple > truth value can be returned, which is faster. > > Note that it has to cope with the subtlety of an object blessed into the > class "0", which should return false. > > Porting/bench.pl shows for the expression !ref($r), approximately: > unchanged for a non-reference $r > doubling of speed for a reference $r > tripling of speed for a blessed reference $r > > This commit builds on the mechanism already used to set the OPpTRUEBOOL > and OPpMAYBE_TRUEBOOL flags on padhv and rv2hv ops when used in boolean > context. > which I've now pushed as v5.27.0-127-gba75e9a -- "But Sidley Park is already a picture, and a most amiable picture too. The slopes are green and gentle. The trees are companionably grouped at intervals that show them to advantage. The rill is a serpentine ribbon unwound from the lake peaceably contained by meadows on which the right amount of sheep are tastefully arranged." -- Lady Croom, "Arcadia"Thread Previous | Thread Next