New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] don't call SvPV and toss the result if no PerlIO ptr #14209
Comments
From @bulk88Created by @bulk88See attached patch. Unsmoked. Perl Info
|
From @bulk880001-don-t-call-SvPV-and-toss-the-result-if-no-PerlIO-ptr.patchFrom bf09951a07524194da0c49f57eb9aa5a4ac8d8a6 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Tue, 4 Nov 2014 20:33:23 -0500
Subject: [PATCH] don't call SvPV and toss the result if no PerlIO ptr
If f is NULL, SvPV and Perl_get_context are unnecessarily executed. Fix
it for efficiency. Move 2nd dTHX to the scope where it is first used
similar to commit 2bcd6579c4 .
---
perlio.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/perlio.c b/perlio.c
index 7eac37f..5d411a2 100644
--- a/perlio.c
+++ b/perlio.c
@@ -5100,11 +5100,13 @@ int
PerlIO_setpos(PerlIO *f, SV *pos)
{
if (SvOK(pos)) {
- STRLEN len;
- dTHX;
- const Off_t * const posn = (Off_t *) SvPV(pos, len);
- if (f && len == sizeof(Off_t))
- return PerlIO_seek(f, *posn, SEEK_SET);
+ if (f) {
+ dTHX;
+ STRLEN len;
+ const Off_t * const posn = (Off_t *) SvPV(pos, len);
+ if(len == sizeof(Off_t))
+ return PerlIO_seek(f, *posn, SEEK_SET);
+ }
}
SETERRNO(EINVAL, SS_IVCHAN);
return -1;
@@ -5114,15 +5116,16 @@ PerlIO_setpos(PerlIO *f, SV *pos)
int
PerlIO_setpos(PerlIO *f, SV *pos)
{
- dTHX;
if (SvOK(pos)) {
- STRLEN len;
- Fpos_t * const fpos = (Fpos_t *) SvPV(pos, len);
- if (f && len == sizeof(Fpos_t)) {
+ if (f) {
+ dTHX;
+ STRLEN len;
+ Fpos_t * const fpos = (Fpos_t *) SvPV(pos, len);
+ if(len == sizeof(Fpos_t))
#if defined(USE_64_BIT_STDIO) && defined(USE_FSETPOS64)
- return fsetpos64(f, fpos);
+ return fsetpos64(f, fpos);
#else
- return fsetpos(f, fpos);
+ return fsetpos(f, fpos);
#endif
}
}
--
1.7.9.msysgit.0
|
From @cpansproutOn Tue Nov 04 17:35:42 2014, bulk88 wrote:
Thank you. Applied as e1a83e7. -- Father Chrysostomos |
The RT System itself - Status changed from 'new' to 'open' |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#123131 (status was 'resolved')
Searchable as RT123131$
The text was updated successfully, but these errors were encountered: