]> git.sesse.net Git - x264/commitdiff
Fix a few static analyzer performance hints
authorAnton Mitrofanov <BugMaster@narod.ru>
Tue, 22 Sep 2015 18:33:07 +0000 (21:33 +0300)
committerHenrik Gramner <henrik@gramner.com>
Sun, 11 Oct 2015 16:44:54 +0000 (18:44 +0200)
encoder/encoder.c
filters/filters.c

index 79997b96ef82fda8838e1eaeeeb7551a3d1aa651..c87d79de2436776e5ac866570ece87f6be5296fb 100644 (file)
@@ -3962,13 +3962,13 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,
     {
         pic_out->prop.f_ssim = h->stat.frame.f_ssim / h->stat.frame.i_ssim_cnt;
         h->stat.f_ssim_mean_y[h->sh.i_type] += pic_out->prop.f_ssim * dur;
-        snprintf( psz_message + strlen(psz_message), 80 - strlen(psz_message),
-                  " SSIM Y:%.5f", pic_out->prop.f_ssim );
+        int msg_len = strlen(psz_message);
+        snprintf( psz_message + msg_len, 80 - msg_len, " SSIM Y:%.5f", pic_out->prop.f_ssim );
     }
     psz_message[79] = '\0';
 
     x264_log( h, X264_LOG_DEBUG,
-                  "frame=%4d QP=%.2f NAL=%d Slice:%c Poc:%-3d I:%-4d P:%-4d SKIP:%-4d size=%d bytes%s\n",
+              "frame=%4d QP=%.2f NAL=%d Slice:%c Poc:%-3d I:%-4d P:%-4d SKIP:%-4d size=%d bytes%s\n",
               h->i_frame,
               h->fdec->f_qp_avg_aq,
               h->i_nal_ref_idc,
index 224f3683e17cb9f3cf101dc42307cfa6f61c2f3e..b3162fe0b0e354135174fd242786fa9c3b907e27 100644 (file)
@@ -32,8 +32,9 @@ char **x264_split_string( char *string, char *sep, int limit )
     if( !string )
         return NULL;
     int sep_count = 0;
+    int sep_len = strlen( sep );
     char *tmp = string;
-    while( ( tmp = ( tmp = strstr( tmp, sep ) ) ? tmp + strlen( sep ) : 0 ) )
+    while( ( tmp = ( tmp = strstr( tmp, sep ) ) ? tmp + sep_len : 0 ) )
         ++sep_count;
     if( sep_count == 0 )
     {
@@ -61,7 +62,7 @@ char **x264_split_string( char *string, char *sep, int limit )
             int j = i-1;
             if( esc )
                 esc[0] = '\0';
-            split[j] = realloc( split[j], strlen( split[j] ) + strlen( sep ) + strlen( tok ) + 1 );
+            split[j] = realloc( split[j], strlen( split[j] ) + sep_len + strlen( tok ) + 1 );
             assert( split[j] );
             strcat( split[j], sep );
             strcat( split[j], tok );