develooper Front page | perl.perl5.porters | Postings from August 2022

Multiple Arrays or One array of structs.

Thread Next
From:
demerphq
Date:
August 3, 2022 12:32
Subject:
Multiple Arrays or One array of structs.
Message ID:
CANgJU+XLmJ3B_L0CUT=yOc-FuKjK7drE5ALSB8TjPXwp-=ZTFg@mail.gmail.com
In the regex engine we have a set of PL_ constants which are related to
introspecting regnode types (opcodes for the regex engine).

If you grep you will find 5:

git grep "PL_regnode_" globvar.sym
globvar.sym:PL_regnode_arg_len
globvar.sym:PL_regnode_arg_len_varies
globvar.sym:PL_regnode_kind
globvar.sym:PL_regnode_name
globvar.sym:PL_regnode_off_by_arg

PL_regnode_name is only used in the debugging regex engine and is an array
of pointers, but the other four are used by both compilation and execution
phase of the regex engine contain mapping data stored as U8.

I have been thinking it would be nice to replace these four/five properties
with one array that contains a struct with the appropriate data in it.
Basically instead of 4 array of U8, have one array of

struct {
    U8 regnode_kind;
    U8 regnode_arg_len;
    U8 regnode_arg_len_varies;
    U8 regnode_off_by_arg;
};

I was wondering if there is any performance reason that this would be a bad
idea? Often two of three of the arrays are used at the same time.  Leaving
PL_regnode_name[] out would be fine.

Cheers,
Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Next


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