develooper Front page | perl.perl5.changes | Postings from September 2021

[Perl/perl5] e893e1: Test that %ENV iteration with prime_env_iter()is ...

From:
Nicholas Clark via perl5-changes
Date:
September 15, 2021 21:24
Subject:
[Perl/perl5] e893e1: Test that %ENV iteration with prime_env_iter()is ...
Message ID:
Perl/perl5/push/refs/heads/blead/c9c667-d5a0a5@github.com
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: e893e12ccfed2a8d5f0649a8cc133249ca7373ff
      https://github.com/Perl/perl5/commit/e893e12ccfed2a8d5f0649a8cc133249ca7373ff
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-15 (Wed, 15 Sep 2021)

  Changed paths:
    M t/op/each.t

  Log Message:
  -----------
  Test that %ENV iteration with prime_env_iter() is consistent


  Commit: d5a0a5dd15db7407246717e8c3e8891b9ba7c53c
      https://github.com/Perl/perl5/commit/d5a0a5dd15db7407246717e8c3e8891b9ba7c53c
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-15 (Wed, 15 Sep 2021)

  Changed paths:
    M hv.c
    M win32/win32.h

  Log Message:
  -----------
  Simplify the code related to prime_env_iter().

Of the platforms that define DYNAMIC_ENV_FETCH, prime_env_iter() is only
needed on VMS, so only call it on VMS. Previously we defined a dummy stub on
Win32 (with PERL_IMPLICIT_SYS defined), and did something different again
for __riscos__.

Remove the dummy definition for win32, and change the conditional compilation
to only call prime_env_iter() on VMS. This removes a call to mg_find() on
Win32, which likely can't be optimised away, as the compiler cannot know that
it has no side effects.

Because`iter` points to a structure immediately after of HvARRAY(), it needs
updating if HvARRAY() has moved because it has been expanded.

Code was added for VMS in Aug 2005 to address this bug with commit
03026e68943709ca:
    [patch@25334] hv.c vms environment fix.
    From: "John E. Malmberg" <wb8tyw@qsl.net>
    Message-ID: <4310F552.8050401@qsl.net>

see https://www.nntp.perl.org/group/perl.perl5.porters/2005/08/msg104261.html

However, the comment added in that code wasn't entirely accurate. The
iteration count doesn't need to be *reset* because prior to that first call
to prime_env_iter() there would be no entries in the hash. In fact, the
iterator *had* to be in its "reset" state - entry == NULL - to enter the
if block. Also, as prime_env_iter() only adds hash values but does not
change the hash's iterator state, it can't change iter->xhv_eiter. Hence
there's no need to re-read *that* value, is it will still be NULL.

Hence the only action needed is to re-initialise iter from HvAUX(), as the
structure it needs to point to has likely been moved in memory by the hash
stores performed by prime_env_iter().


Compare: https://github.com/Perl/perl5/compare/c9c66756259a...d5a0a5dd15db



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About