Skip to content

Commit 16bd110

Browse files
committed
Small performance improvement. The current code is correct, but if it is used inside a long loop or long strings, it's inefficient.
1 parent 14f120d commit 16bd110

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

main/rfc1867.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header T
408408

409409
/* get lines of text, or CRLF_CRLF */
410410

411-
while( (line = get_line(self TSRMLS_CC)) && strlen(line) > 0 )
411+
while( (line = get_line(self TSRMLS_CC)) && line[0] != '\0' )
412412
{
413413
/* add header to table */
414414
char *key = line;
@@ -979,7 +979,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
979979
continue;
980980
}
981981

982-
if (strlen(filename) == 0) {
982+
if (filename[0] == '\0') {
983983
#if DEBUG_FILE_UPLOAD
984984
sapi_module.sapi_error(E_NOTICE, "No file uploaded");
985985
#endif
@@ -1063,12 +1063,12 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
10631063

10641064
if (!cancel_upload && !end) {
10651065
#if DEBUG_FILE_UPLOAD
1066-
sapi_module.sapi_error(E_NOTICE, "Missing mime boundary at the end of the data for file %s", strlen(filename) > 0 ? filename : "");
1066+
sapi_module.sapi_error(E_NOTICE, "Missing mime boundary at the end of the data for file %s", filename[0] != '\0' ? filename : "");
10671067
#endif
10681068
cancel_upload = UPLOAD_ERROR_C;
10691069
}
10701070
#if DEBUG_FILE_UPLOAD
1071-
if (strlen(filename) > 0 && total_bytes == 0 && !cancel_upload) {
1071+
if (filename[0] != '\0' && total_bytes == 0 && !cancel_upload) {
10721072
sapi_module.sapi_error(E_WARNING, "Uploaded file size 0 - file [%s=%s] not saved", param, filename);
10731073
cancel_upload = 5;
10741074
}

0 commit comments

Comments
 (0)