[FFmpeg-devel] [PATCH 1/4] lavf/segment: Simplify CSV field quoting code

Alexander Strasser eclipse7 at gmx.net
Sat Sep 15 01:06:50 CEST 2012


Should also be faster (though I doubt that hardly
ever matters for the usage here).

Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
 libavformat/segment.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index dc12349..6dde547 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -77,14 +77,7 @@ typedef struct {
 static void print_csv_escaped_str(AVIOContext *ctx, const char *str)
 {
     const char *p;
-    int quote = 0;
-
-    /* check if input needs quoting */
-    for (p = str; *p; p++)
-        if (strchr("\",\n\r", *p)) {
-            quote = 1;
-            break;
-        }
+    int quote = !!str[strcspn(str, "\",\n\r")];
 
     if (quote)
         avio_w8(ctx, '"');
-- 
1.7.10.2.552.gaa3bb87


More information about the ffmpeg-devel mailing list