Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • A second class you should look at Auto-XS'ifying is constants.

    Something like sub { 1 } turns into dramatically faster XS.
    • That should be happening anyway, right? Perhaps only if you write sub () {1}.

      The next thing I might tackle is setters. However, since those come in a much wider variety than getters, it'll take some better matching tools than what we have now in B::Utils. Just look at the code of AutoXS::Accessor for a sample of what kind of cruft I produced.

      So as a yak shaving exercise, I'd like to write two routines: One that produces a pattern/condition structure for B::Util's opgrep() from an existing op tree and one that, given two such patterns, does an alternation of them. This is already there as op_or(), but what I'd want it to do is merge as much of the structures as possible:


        op_or(
          { name => 'foo', first => { name => 'bar' } }
          { name => 'foo', first => { name => 'baz' } }
        )


      currently becomes


        {
            disjunction => [
              { name => 'foo', first => { name => 'bar' } }
              { name => 'foo', first => { name => 'baz' } }
        }


      whereas it should be in an ideal world:


        {
            name => 'foo',
            first => {
                disjunction => [
                  { name => 'bar' },
                  { name => 'baz' }
                ],
            }
        }


      Or, even better:


        {
            name => 'foo',
            first => { name => ['bar', 'baz'] }
        }


      But then again, I'm probably not going to have time to do any of this any time soon. My XS learning time is spent for now and I have to get back to work and - Yay - my first teaching assignment.
      • sub () { 1 } gets you part of the way.

        But the XS version is even faster again.
      • I just wrote the code to produce opgrep patterns from op trees (I.e. B::OP objects). Expect B::Utils 0.05_06 on CPAN soonish.

        Oh, and there is a typo in my last comment. The second code snippet is missing a closing ]. Sorry about that.