Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 8fb50b67f2c813eda16c2c2653e6e93629c55e5e
      
https://github.com/Perl/perl5/commit/8fb50b67f2c813eda16c2c2653e6e93629c55e5e
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Rename variables

These are running totals; I and others have gotten confused at times
over their names prior to this commit as implying they are the end
result.


  Commit: a39f9ecba823b845f333a1864211db267fe7aea7
      
https://github.com/Perl/perl5/commit/a39f9ecba823b845f333a1864211db267fe7aea7
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Avoid unnecessary operations

We know the value of 'accumulated' here is 0, so no need to have the
generality of it being non-zero.


  Commit: 7d802a5985bc51723b745c3ab7c4c47856858145
      
https://github.com/Perl/perl5/commit/7d802a5985bc51723b745c3ab7c4c47856858145
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: indentation only

The important code in this switch was not aligned to a multiple of 4
spaces.


  Commit: 1f089538bbb2f4306153cac1ee4a994ff2f3243d
      
https://github.com/Perl/perl5/commit/1f089538bbb2f4306153cac1ee4a994ff2f3243d
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Optimize for 8 or fewer digits

This commit effectively stops throwing away easily derivable
information.  Prior to it, at the end of the switch, there were two
possible cases that had to be checked for:
    1) A non-legal-digit character was found in the input; or
    2) The input was too long to be handled by the switch().

By adding a case: for just too-long input, and jumping past the end of
the switch(), case 2) is no longer possible there; at the cost of the
compiler adding an extra element to the switch's jump table.

But this does change the flow of things.  Previously, the first
up-through 8 characters of the string were handled in the switch, and
then, if any remain, loop.  The new operation is to use the loop to
handle all the characters of a string that's longer than 8, and to use
the switch to handle only those strings that contain 8 or fewer
characters.

The intent of the switch() is to make this task as fast as possible for
the more common scenario.  This commit makes it slightly faster, at the
expense of longer strings.

This commit does not yet take advantage of the jump out of the longer
strings not having to deal with illegal characters.  The next few
commits will do that.

This commit also temporarily removes some special consideration for
leading zeroes, which are less common.  Later commits will restore
this.

The commit changes the default: in the switch to be for 9 or more
digits, and just jumps out.  It adds a case for 8 digits.  The result is
that after all the falling through to the end of the case statements, we
can return immediately without needing further checking.

Having the default: case be for longer values also presents optimization
possibilities to be done in future commits

8 digits was chosen because that's the highest number that can be
accommodated without having to worry about anything else.  9 hex digits
can trigger a portability warning for base 16.


  Commit: 5f1f7692f0177f6e56b0f3545cf130b5a74d53bc
      
https://github.com/Perl/perl5/commit/5f1f7692f0177f6e56b0f3545cf130b5a74d53bc
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Move/change some initialization

This is in preparation for the next commit which will use goto's to
avoid some work, which would cross some initializations.  This moves
some initialization to before the goto's, and splits some more local
values to declare followed by initialization.  Some of these changes
will be removed in future commits


  Commit: d54469d579e69302c49859dc5d9b8c2a562a78a3
      
https://github.com/Perl/perl5/commit/d54469d579e69302c49859dc5d9b8c2a562a78a3
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Move conditional clause out of loop

This clause is only possibly true the first time through the loop.  Move
it to before the loop, to the one place it could be true.


  Commit: db810e7c124245cba5dbd36e02abb419b35535f4
      
https://github.com/Perl/perl5/commit/db810e7c124245cba5dbd36e02abb419b35535f4
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Macroize expression

This is in preparation for it being called from other places


  Commit: 6b4a704bec782caf5556d50f1092e984ee0fe9a3
      
https://github.com/Perl/perl5/commit/6b4a704bec782caf5556d50f1092e984ee0fe9a3
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Make loop entry conditions consistent

By a bit more work before the loop, we can make this consistent, which
presents optimization possibilities for future commits


  Commit: d7db50c0030c38211a3286bde0494a5e3204131d
      
https://github.com/Perl/perl5/commit/d7db50c0030c38211a3286bde0494a5e3204131d
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Change param name to match embed.fnc

The embed.fnc name is clearer


  Commit: d0f8d61d3b917138477a06b4319f03dc64c02581
      
https://github.com/Perl/perl5/commit/d0f8d61d3b917138477a06b4319f03dc64c02581
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Reinstate handling leading zeros specially


  Commit: c12910fa99457365b688176ecb8213f9c91aecda
      
https://github.com/Perl/perl5/commit/c12910fa99457365b688176ecb8213f9c91aecda
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Start loop with fresh character

We get to this loop from two places.  It leads to some future
optimizations to make them both have accumulated their current digit,
and position the parse pointer to the next one up.


  Commit: e9b12f42651aa548caad5b84df65a90d15ac4fbe
      
https://github.com/Perl/perl5/commit/e9b12f42651aa548caad5b84df65a90d15ac4fbe
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Mv leading zero handling from loop

This code in the loop is only helpful in early iterations of it, and is
an unnecessary conditional otherwise.  By creating a loop that
accomplishes the same thing in the default: case of the switch, we do
the task at just the beginning, and remove the need for it to be checked
for every time in the main loop.


  Commit: 407de75733b0a49c8ec4dc8c9df55fb90a47c0a4
      
https://github.com/Perl/perl5/commit/407de75733b0a49c8ec4dc8c9df55fb90a47c0a4
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Swap code order

The previous (self-described as "wonky") ordering was to make the common
case get compiled as a tight loop.  I believe that the branch
prediction here should enable a compiler to figure that out, and this
makes it easier to understand, with a natural progression with the
first, unlikely, clause falling through to the other one.


  Commit: 540bb3ed070b36055e9e8d0d1de55a25881e012b
      
https://github.com/Perl/perl5/commit/540bb3ed070b36055e9e8d0d1de55a25881e012b
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Don't execute loop for illegal characters

This adds a conditional to the loop entrance to skip it if the character
is illegal, making some code inside the loop unnecessary.

Thus this adds a test at the top of the loop, and removes a test inside
it.


  Commit: de76945cf0f08ed314358ec23146c6e8be3b6cd7
      
https://github.com/Perl/perl5/commit/de76945cf0f08ed314358ec23146c6e8be3b6cd7
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Outdent

The surrounding block to this code was removed in the previous commit.


  Commit: 453b4bef675c3c49a8fca7a3df774bba1dec511d
      
https://github.com/Perl/perl5/commit/453b4bef675c3c49a8fca7a3df774bba1dec511d
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Move overflow handling out of loop

It turns out that there is a different algorithm that loses less
precision than the current one when handling overflows, but is less
efficient.  But overflowing is a rare case, and precision matters, so a
future commit will change to use the new method.

This commit just moves the overflow handling outside the loop it had
been in, so that the new algorithm can be implemented without disturbing
the non-overflow case, whose algorithm works fine.


  Commit: 6958020d975033fcca1452a62fcf1fea25c31814
      
https://github.com/Perl/perl5/commit/6958020d975033fcca1452a62fcf1fea25c31814
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Outdent

The block around this has been eliminated


  Commit: 1ea6f282c7f02c45bf406f72a43122d39e129f0b
      
https://github.com/Perl/perl5/commit/1ea6f282c7f02c45bf406f72a43122d39e129f0b
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Eliminate a variable

It turns out that another existing variable is all that is needed.


  Commit: c26120dda66c03975c85274ce8bba0de5e95cf25
      
https://github.com/Perl/perl5/commit/c26120dda66c03975c85274ce8bba0de5e95cf25
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Change variable name

The next commit changes how this is used; this commit is just to make
the diff listing in that commit smaller


  Commit: c446c1c927da1669cbabeefeac271ca48f80aff9
      
https://github.com/Perl/perl5/commit/c446c1c927da1669cbabeefeac271ca48f80aff9
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Use more accurate algorithm for overflow

The previous algorithm loses more precision than this one.  It did not
show up in our test suite, but a WIP I have did show that, and this new
algorithm fixes it.

The problem with the old one is that it started with the highest order
digits, and worked down to the low order which don't contribute very
much to result, but they can contribute more than what that algorithm
used.  This is because those low order digits can end up contributing
nothing, being dwarfed by the high order ones.

The new algorithm doesn't take effect until the rare case that the input
string overflows.  It finds the end of the input digits and then works
backwards.  For example, in the string 0x123, it calculates
    3 * 1 + 2 * 16 + 1 * 256
It creates batches of these that don't overflow and then combines them
with the previous set of batches, like the old algorithm, except working
backwards.

Each new batch will contribute to the overall value, instead of being
discarded.  The previous batches which are lower order will become less
and less important, but their contribution is not prematurely discarded,
which is the effect of the old algorithm.

The extra inefficiency is due to finding the end of the string, and then
reparsing it backwards.  But again, this only happens when overflow
occurs.


  Commit: afd3f69630e90a13004345d3ce62ef7da57d8159
      
https://github.com/Perl/perl5/commit/afd3f69630e90a13004345d3ce62ef7da57d8159
  Author: Karl Williamson <[email protected]>
  Date:   2026-02-01 (Sun, 01 Feb 2026)

  Changed paths:
    M numeric.c

  Log Message:
  -----------
  grok_bin_oct_hex: Change for() to while()

I tend to think of while() as being easier to understand than for loops;
and previous commits have eliminated all but one place to increment the
parse pointer.


Compare: https://github.com/Perl/perl5/compare/bfbe774da9fc...afd3f69630e9

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

Reply via email to