Skip to content

Commit 5144e0d

Browse files
committed
Convert Perl_hv_foo to hv_foo and rm from mathoms
These four functions (example Perl_hv_delete), can be converted to call their plain macro (e.g. hv_delete) without changing their behavior. I verified this by eyeballing their implementations in mathoms.c and comparing that with what happens with just the plain macro. That means embed.fnc can be changed to generate the Perl_ forms automatically, and the mathoms functions can be removed.
1 parent c1ae415 commit 5144e0d

File tree

4 files changed

+25
-98
lines changed

4 files changed

+25
-98
lines changed

embed.fnc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ ARdp |HV * |hv_copy_hints_hv \
14881488
Cp |void |hv_delayfree_ent \
14891489
|NULLOK HV *notused \
14901490
|NULLOK HE *entry
1491-
AMbdp |SV * |hv_delete |NULLOK HV *hv \
1491+
Admp |SV * |hv_delete |NULLOK HV *hv \
14921492
|NN const char *key \
14931493
|I32 klen \
14941494
|I32 flags
@@ -1508,13 +1508,13 @@ dp |void |hv_ename_delete|NN HV *hv \
15081508
|NN const char *name \
15091509
|U32 len \
15101510
|U32 flags
1511-
AMRbdp |bool |hv_exists |NULLOK HV *hv \
1511+
ARdmp |bool |hv_exists |NULLOK HV *hv \
15121512
|NN const char *key \
15131513
|I32 klen
15141514
ARdmp |bool |hv_exists_ent |NULLOK HV *hv \
15151515
|NN SV *keysv \
15161516
|U32 hash
1517-
AMbdp |SV ** |hv_fetch |NULLOK HV *hv \
1517+
Admp |SV ** |hv_fetch |NULLOK HV *hv \
15181518
|NN const char *key \
15191519
|I32 klen \
15201520
|I32 lval
@@ -1563,7 +1563,7 @@ Cdop |void |hv_riter_set |NN HV *hv \
15631563
|I32 riter
15641564

15651565
ARdp |SV * |hv_scalar |NN HV *hv
1566-
AMbdp |SV ** |hv_store |NULLOK HV *hv \
1566+
Admp |SV ** |hv_store |NULLOK HV *hv \
15671567
|NULLOK const char *key \
15681568
|I32 klen \
15691569
|NULLOK SV *val \

embed.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,11 +2280,15 @@
22802280
# define Perl_gv_efullname3(mTHX,a,b,c) gv_efullname3(a,b,c)
22812281
# define Perl_gv_fetchmethod(mTHX,a,b) gv_fetchmethod(a,b)
22822282
# define Perl_gv_fullname3(mTHX,a,b,c) gv_fullname3(a,b,c)
2283+
# define Perl_hv_delete(mTHX,a,b,c,d) hv_delete(a,b,c,d)
22832284
# define Perl_hv_delete_ent(mTHX,a,b,c,d) hv_delete_ent(a,b,c,d)
2285+
# define Perl_hv_exists(mTHX,a,b,c) hv_exists(a,b,c)
22842286
# define Perl_hv_exists_ent(mTHX,a,b,c) hv_exists_ent(a,b,c)
2287+
# define Perl_hv_fetch(mTHX,a,b,c,d) hv_fetch(a,b,c,d)
22852288
# define Perl_hv_fetch_ent(mTHX,a,b,c,d) hv_fetch_ent(a,b,c,d)
22862289
# define Perl_hv_iternext(mTHX,a) hv_iternext(a)
22872290
# define Perl_hv_magic(mTHX,a,b,c) hv_magic(a,b,c)
2291+
# define Perl_hv_store(mTHX,a,b,c,d,e) hv_store(a,b,c,d,e)
22882292
# define Perl_hv_store_ent(mTHX,a,b,c,d) hv_store_ent(a,b,c,d)
22892293
# define Perl_hv_store_flags(mTHX,a,b,c,d,e,f) hv_store_flags(a,b,c,d,e,f)
22902294
# define Perl_newAV(mTHX) newAV()
@@ -2335,11 +2339,15 @@
23352339
# define Perl_gv_efullname3 gv_efullname3
23362340
# define Perl_gv_fetchmethod gv_fetchmethod
23372341
# define Perl_gv_fullname3 gv_fullname3
2342+
# define Perl_hv_delete hv_delete
23382343
# define Perl_hv_delete_ent hv_delete_ent
2344+
# define Perl_hv_exists hv_exists
23392345
# define Perl_hv_exists_ent hv_exists_ent
2346+
# define Perl_hv_fetch hv_fetch
23402347
# define Perl_hv_fetch_ent hv_fetch_ent
23412348
# define Perl_hv_iternext hv_iternext
23422349
# define Perl_hv_magic hv_magic
2350+
# define Perl_hv_store hv_store
23432351
# define Perl_hv_store_ent hv_store_ent
23442352
# define Perl_hv_store_flags hv_store_flags
23452353
# define Perl_newAV newAV

mathoms.c

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -202,80 +202,6 @@ Perl_sv_nounlocking(pTHX_ SV *sv)
202202
PERL_UNUSED_ARG(sv);
203203
}
204204

205-
SV**
206-
Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
207-
{
208-
STRLEN klen;
209-
int flags;
210-
211-
if (klen_i32 < 0) {
212-
klen = -klen_i32;
213-
flags = HVhek_UTF8;
214-
} else {
215-
klen = klen_i32;
216-
flags = 0;
217-
}
218-
return (SV **) hv_common(hv, NULL, key, klen, flags,
219-
(HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
220-
}
221-
222-
bool
223-
Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
224-
{
225-
STRLEN klen;
226-
int flags;
227-
228-
PERL_ARGS_ASSERT_HV_EXISTS;
229-
230-
if (klen_i32 < 0) {
231-
klen = -klen_i32;
232-
flags = HVhek_UTF8;
233-
} else {
234-
klen = klen_i32;
235-
flags = 0;
236-
}
237-
return cBOOL(hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0));
238-
}
239-
240-
SV**
241-
Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
242-
{
243-
STRLEN klen;
244-
int flags;
245-
246-
PERL_ARGS_ASSERT_HV_FETCH;
247-
248-
if (klen_i32 < 0) {
249-
klen = -klen_i32;
250-
flags = HVhek_UTF8;
251-
} else {
252-
klen = klen_i32;
253-
flags = 0;
254-
}
255-
return (SV **) hv_common(hv, NULL, key, klen, flags,
256-
lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
257-
: HV_FETCH_JUST_SV, NULL, 0);
258-
}
259-
260-
SV *
261-
Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
262-
{
263-
STRLEN klen;
264-
int k_flags;
265-
266-
PERL_ARGS_ASSERT_HV_DELETE;
267-
268-
if (klen_i32 < 0) {
269-
klen = -klen_i32;
270-
k_flags = HVhek_UTF8;
271-
} else {
272-
klen = klen_i32;
273-
k_flags = 0;
274-
}
275-
return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
276-
NULL, 0));
277-
}
278-
279205
HV *
280206
Perl_newHV(pTHX)
281207
{

proto.h

Lines changed: 13 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)