Skip to content

Commit 68d4480

Browse files
committed
Perl_do_print: code readability improvements suggested in GH#22927
1 parent c391e0f commit 68d4480

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

doio.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,6 @@ Perl_do_print(pTHX_ SV *sv, PerlIO *fp)
22052205
return TRUE;
22062206
if (SvTYPE(sv) == SVt_IV && SvIOK(sv)) {
22072207
assert(!SvGMAGICAL(sv));
2208-
bool happy = TRUE;
22092208

22102209
/* Adapted from Perl_sv_2pv_flags */
22112210
const U32 isUIOK = SvIsUV(sv);
@@ -2221,16 +2220,14 @@ Perl_do_print(pTHX_ SV *sv, PerlIO *fp)
22212220
ptr = uiv_2buf(buf.arr, SvIVX(sv), tempuv, isUIOK, &ebuf);
22222221
len = ebuf - ptr;
22232222

2224-
if (len && (PerlIO_write(fp,ptr,len) == 0))
2225-
happy = FALSE;
2226-
return happy ? !PerlIO_error(fp) : FALSE;
2223+
bool happy = !(len && (PerlIO_write(fp,ptr,len) == 0));
2224+
return happy && !PerlIO_error(fp);
22272225
}
22282226
else {
22292227
STRLEN len;
22302228
/* Do this first to trigger any overloading. */
22312229
const char *tmps = SvPV_const(sv, len);
22322230
U8 *tmpbuf = NULL;
2233-
bool happy = TRUE;
22342231

22352232
if (PerlIO_isutf8(fp)) { /* If the stream is utf8 ... */
22362233
if (!SvUTF8(sv)) { /* Convert to utf8 if necessary */
@@ -2273,10 +2270,9 @@ Perl_do_print(pTHX_ SV *sv, PerlIO *fp)
22732270
* but only until the system hard limit/the filesystem limit,
22742271
* at which we would get EPERM. Note that when using buffered
22752272
* io the write failure can be delayed until the flush/close. --jhi */
2276-
if (len && (PerlIO_write(fp,tmps,len) == 0))
2277-
happy = FALSE;
2273+
bool happy = !(len && (PerlIO_write(fp,tmps,len) == 0));
22782274
Safefree(tmpbuf);
2279-
return happy ? !PerlIO_error(fp) : FALSE;
2275+
return happy && !PerlIO_error(fp);
22802276
}
22812277
}
22822278

0 commit comments

Comments
 (0)