Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 4545edd2d3a71f0dbf587c9b423ce8dca894bf1e
      
https://github.com/Perl/perl5/commit/4545edd2d3a71f0dbf587c9b423ce8dca894bf1e
  Author: Karl Williamson <[email protected]>
  Date:   2026-01-29 (Thu, 29 Jan 2026)

  Changed paths:
    M handy.h
    M regen/embed.pl

  Log Message:
  -----------
  Create Perl_isCC_by_bit()

Perl_isCC_by_bit(),not part of the public API, returns a boolean as to
whether or not a character is a member of a class or classes, as
determined by PL_charclass[].  Besides the character, it takes a bit
argument, as given by the return of CC_mask_.

I think it is instructive as to how these macros came to be.  I created
PL_charclass[] a long time ago to speed up character classification, so
that instead of several if..else.. statements, one could do a simple
array lookup to see if a character is a \w, for example.

I envisioned this as being used for things like isWORDCHAR, where the
class number was baked-in to the macro name.

Over time, cases where the class number was not known until runtime
presented themselves.  It was easy to just use the base macros for that,
and everything worked.  But what I neglected, and no one caught, is that
there is a runtime cost to deriving the bit position from the class
number.   But Tony Cook noticed recently that grok_bin_oct_hex()
rederives that same value multiple times.

So this macro has been invented to avoid that multiple runtime cost.


  Commit: d95873289354b499ee3c786f5847a5c676056a1a
      
https://github.com/Perl/perl5/commit/d95873289354b499ee3c786f5847a5c676056a1a
  Author: Karl Williamson <[email protected]>
  Date:   2026-01-29 (Thu, 29 Jan 2026)

  Changed paths:
    M embed.fnc
    M inline.h
    M numeric.c
    M proto.h

  Log Message:
  -----------
  Use Perl_isCC_by_bit() to do calcs at compile time

grok_bin_oct_hex() is the common function to implement grokking a string
of digits in any of the three bases.  Prior to this commit, the
individual functions were calling the common one with a bit position
that corresponded to the proper base.  But the common function needs to
use not the bit position, but the actual bit in that position.  It ended
up rederiving that value multiple times.  This commit changes to pass
the bit, and not the position.  This is known at compile time in the
individual functions, so the net effect is the removal of a bunch of
runtime calculations.  And, it allows for more generality, should we
ever change so that the bit pattern is a combination of bits.


Compare: https://github.com/Perl/perl5/compare/d10217e702eb...d95873289354

To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications

Reply via email to