diff mbox

[FFmpeg-devel,v3,1/2] avformat/utils: simplify the code and remove av_strncasecmp

Message ID 20191202045106.27737-1-lance.lmwang@gmail.com
State New
Headers show

Commit Message

Lance Wang Dec. 2, 2019, 4:51 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/utils.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer Dec. 3, 2019, 8:43 a.m. UTC | #1
On Mon, Dec 02, 2019 at 12:51:05PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavformat/utils.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 8196442dd1..03a3705200 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4854,11 +4854,10 @@ int ff_mkdir_p(const char *path)
>          return -1;
>      }
>  
> -    if (!av_strncasecmp(temp, "/", 1) || !av_strncasecmp(temp, "\\", 1)) {
> +    if (*temp == '/' || *temp == '\\')
>          pos++;

> -    } else if (!av_strncasecmp(temp, "./", 2) || !av_strncasecmp(temp, ".\\", 2)) {
> +    else if (*temp == '.' && (*(temp+1) == '/' || *(temp+1) == '\\'))

is this really simpler ? (compared to strncmp() for example) ?
it looks more obfuscated 

also not sure about the {} removial

[...]
Lance Wang Dec. 3, 2019, 2:05 p.m. UTC | #2
On Tue, Dec 03, 2019 at 09:43:53AM +0100, Michael Niedermayer wrote:
> On Mon, Dec 02, 2019 at 12:51:05PM +0800, lance.lmwang@gmail.com wrote:
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavformat/utils.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index 8196442dd1..03a3705200 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -4854,11 +4854,10 @@ int ff_mkdir_p(const char *path)
> >          return -1;
> >      }
> >  
> > -    if (!av_strncasecmp(temp, "/", 1) || !av_strncasecmp(temp, "\\", 1)) {
> > +    if (*temp == '/' || *temp == '\\')
> >          pos++;
> 
> > -    } else if (!av_strncasecmp(temp, "./", 2) || !av_strncasecmp(temp, ".\\", 2)) {
> > +    else if (*temp == '.' && (*(temp+1) == '/' || *(temp+1) == '\\'))
> 
> is this really simpler ? (compared to strncmp() for example) ?
> it looks more obfuscated 
It's changed for patch#2, for the separator is defined as single
charactor. so it's more simple to compare with character.  

> 
> also not sure about the {} removial
Yes, it's unrelated cosmetics change, I'll keep it if have chance to update the patchset.

> 
> [...]
> 
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> No human being will ever know the Truth, for even if they happen to say it
> by chance, they would not even known they had done so. -- Xenophanes



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8196442dd1..03a3705200 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4854,11 +4854,10 @@  int ff_mkdir_p(const char *path)
         return -1;
     }
 
-    if (!av_strncasecmp(temp, "/", 1) || !av_strncasecmp(temp, "\\", 1)) {
+    if (*temp == '/' || *temp == '\\')
         pos++;
-    } else if (!av_strncasecmp(temp, "./", 2) || !av_strncasecmp(temp, ".\\", 2)) {
+    else if (*temp == '.' && (*(temp+1) == '/' || *(temp+1) == '\\'))
         pos += 2;
-    }
 
     for ( ; *pos != '\0'; ++pos) {
         if (*pos == '/' || *pos == '\\') {