summaryrefslogtreecommitdiff
path: root/mro_core.c
Commit message (Collapse)AuthorAgeFilesLines
* pod/perlmroapi.pod - document linear MRO function return type.Paul "LeoNerd" Evans2023-02-081-2/+3
| | | | | Small docs clarification to point out that the linear MRO function returns a list of strings
* mro_core.c - define PERL_IN_MRO_CORE_C as wellYves Orton2022-12-241-0/+1
| | | | | | | | | | | Each core file defines a symbol which represents that its in that file. Sometime where we split or move code around this ends up with a file claiming to be another file. This is fine, but it should also define its own file specific define. Currently this isn't used. But if we ever want to restrict functions in this file to just this file (eg a static function) we will need this define.
* change HvENAME_HEK() to HvENAME_HEK_NN() where NULLs would crash anywayTony Cook2022-11-181-6/+7
| | | | | | | | | | | | | | | | | | | | | gcc 12 was producing a confusing message complaining that references to with hek_key[] were beyond the end of the array, even though a properly HEK has bytes beyond the first we declare. From experimentation I theorize the confusing message was produced because HvENAME_HEK() can return a NULL pointer, and the array pointed to by any NULL pointer is zero length, producing the array bounds warning we were seeing. Fixed by changing each hv_(fetch|delete)hek() call to use the HvENAME_HEK_NN() macro variant, which doesn't include an explicit NULL return value. mro_method_changed_in() was a bit special, it evaluated the hv_fetchhek() before the check for an anonymous stash, so I reordered the code to take advantage of C99, checking the assertions before we dereference the stash pointer, checking we have a name before trying to look it up.
* only fully calculate the stash (effective) name where neededTony Cook2022-11-181-5/+5
| | | | | | | | | gcc 12 was complaining that evaluating (somehekptr)->hek_key was always true in many places where HvNAME() or HvENAME() was being called in boolean context. Add new macros to check whether the names should be available and use those instead.
* Replace sv_2mortal(newSVhek( with newSVhek_mortalRichard Leach2022-08-051-1/+1
| | | | The new Perl_newSVhek_mortal function is slightly more efficient.
* Use HvHasAUX() rather than SvOOK() when operating on HVsPaul "LeoNerd" Evans2022-07-021-2/+2
|
* Make use of av_push_simple in a few places.Richard Leach2022-06-081-6/+6
| | | | | | | | | Specifically, only where a new AV has just been created and it's therefore obvious that av_push_simple is safe to use. In many cases, nearby code does av_push to an existing array. It might well be the case that these are simple arrays and av_push_simple could be used instead. The necessary analysis has been left for the future.
* perlapi: Document mro_get_from_name, mro_set_mroKarl Williamson2022-05-181-0/+20
|
* Perl_newSV_type_mortal - new inline function introduced and usedRichard Leach2022-03-071-11/+11
| | | | | | | | | | | | | | | There's no efficient way to create a mortal SV of any type other than SVt_NULL (via sv_newmortal). The options are either to do: * SV* sv = sv_newmortal; sv_upgrade(sv, SVt_SOMETYPE); but sv_upgrade is needlessly inefficient on new SVs. * SV* sv = sv_2mortal(newSV_type(SVt_SOMETYPE) but this will perform runtime checks to see if (sv) and if (SvIMMORTAL(sv), and for a new SV we know that those answers will always be yes and no. This commit adds a new inline function which is basically a mortalizing wrapper around the now-inlined newSV_type.
* Only call S_mro_clean_isarev() if HvTOTALKEYS() is non-zeroNicholas Clark2021-09-031-17/+19
| | | | | Two callers already had an "is it empty?" check. Add this to the third caller, and hence remove the duplicated internal check.
* Pre-extend the ISA hash in Perl_mro_get_linear_isa().Nicholas Clark2021-08-231-1/+6
|
* S_mro_gather_and_rename() can use HvTOTALKEYS(), as placeholders don't matter.Nicholas Clark2021-07-261-4/+5
| | | | | | | | | Stashes *shouldn't* have placeholders, but even if they did, the loop skips if !isGV(val) is true, which will hold for placeholders. Also move the call to hv_fetchhek() after the check for main::main::main::... The C compiler can't optimise that call away because it doesn't know whether it has has side effects. We know that it doesn't, so we can move it.
* Convert code in mro_core.c to use hv_*hek() APIs where possible.Nicholas Clark2021-07-261-9/+7
| | | | | | | | Add a macro hv_existshek() to implement exists. The HEK-based macros are more efficient wrappers of hv_common() than the string/length/flags macros because they also pass in the pre-computed hash value (from the HEK). This avoids hv_common() needing to recalculate it.
* Where the key is an SV, replace some hv_* calls with hv_*_ent equivalents.Nicholas Clark2021-07-261-4/+4
| | | | | This avoids the SvUTF8(tmpstr) ? -(I32)SvCUR(tmpstr) : (I32)SvCUR(tmpstr) code dance.
* style: Detabify indentation of the C code maintained by the core.Michael G. Schwern2021-01-171-594/+594
| | | | | | | | | | | This just detabifies to get rid of the mixed tab/space indentation. Applying consistent indentation and dealing with other tabs are another issue. Done with `expand -i`. * vutil.* left alone, it's part of version. * Left regen managed files alone for now.
* Reorganize perlapiKarl Williamson2020-09-041-1/+1
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* Fix: local variable hiding parameter of same nameJames E Keenan2019-11-121-4/+4
| | | | | | | | | | | | | | | | LGTM provides static code analysis and recommendations for code quality improvements. Their recent run over the Perl 5 core distribution identified 12 instances where a local variable hid a parameter of the same name in an outer scope. The LGTM rule governing this situation can be found here: Per: https://lgtm.com/rules/2156240606/ This patch renames local variables in approximately 8 of those instances to comply with the LGTM recommendation. Suggestions for renamed variables were made by Tony Cook. For: https://github.com/Perl/perl5/pull/17281
* Note that mro[gs]et_private_data are documentedKarl Williamson2019-09-021-1/+3
|
* Restore lost line from commentHugo van der Sanden2018-07-171-1/+1
| | | | This somehow disappeared in the mro => mro_core rename of 8b371338c1.
* Use memEQs, memNEs in core filesKarl Williamson2017-11-061-2/+2
| | | | | | | | | | Where the length is known, we can use these functions which relieve the programmer and the program reader from having to count characters. The memFOO functions should also be slightly faster than the strFOO equivalents. In some instances in this commit, hard coded numbers are used. These come from the 'case' statement values that apply to them.
* Change white space to avoid C++ deprecation warningKarl Williamson2016-11-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | C++11 requires space between the end of a string literal and a macro, so that a feature can unambiguously be added to the language. Starting in g++ 6.2, the compiler emits a warning when there isn't a space (presumably so that future versions can support C++11). Unfortunately there are many such instances in the perl core. This commit fixes those, including those in ext/, but individual commits will be used for the other modules, those in dist/ and cpan/. This commit also inserts space at the end of a macro before a string literal, even though that is not deprecated, and removes useless "" literals following a macro (instead of inserting a blank). The result is easier to read, making the macro stand out, and be clearer as to the intention. Code and modules included with the Perl core need to be compilable using C++. This is so that perl can be embedded in C++ programs. (Actually, only the hdr files need to be so compilable, but it would be hard to test that just the hdrs are compilable.) So we need to accommodate changes to the C++ language.
* mro_core.c: use new SvPVCLEAR and constant string friendly macrosYves Orton2016-10-191-7/+7
|
* [perl #126410] keep the DESTROY cache in mro_metaTony Cook2016-02-081-5/+9
| | | | | | | | | | | | | We're already keeping destroy_gen there, so keep the CV there too. The previous implementation, introduced in 8c34e50d, kept the destroy method cache in the stash's stash, which broke B's SvSTASH method. Before that, the DESTROY method was cached in overload magic. A previous version of this patch didn't clear the destructor cache on a clone, which caused ext/XS-APItest/t/clone_with_stack.t to fail.
* Various pods: Add C<> around many typed-as-is thingsKarl Williamson2015-09-031-2/+2
| | | | Removes 'the' in front of parameter names in some instances.
* perlapi: Use F<> around file namesKarl Williamson2015-08-011-1/+1
|
* Replace common Emacs file-local variables with dir-localsDagfinn Ilmari Mannsåker2015-03-221-6/+0
| | | | | | | | | | | | | | | | An empty cpan/.dir-locals.el stops Emacs using the core defaults for code imported from CPAN. Committer's work: To keep t/porting/cmp_version.t and t/porting/utils.t happy, $VERSION needed to be incremented in many files, including throughout dist/PathTools. perldelta entry for module updates. Add two Emacs control files to MANIFEST; re-sort MANIFEST. For: RT #124119.
* Change name of mro.cKarl Williamson2015-03-191-0/+1429
This is to prevent a conflict showing up on z/OS (os390) because this file's name is the same as one in /ext, and there are functions cross-referenced between them, and the loader on that platform can't deal with this. See http://nntp.perl.org/group/perl.perl5.porters/226612