libarchive: open_zipped() does not need to check extensions for e.g. gzip
[oweals/busybox.git] / libbb / safe_strncpy.c
index 4acd9766ba7c896076826e0f538d7fddc55af8f2..5eb0db0bd4c5732e47e94eadd94d0fa403525b33 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 #include "libbb.h"
@@ -20,8 +20,13 @@ char* FAST_FUNC safe_strncpy(char *dst, const char *src, size_t size)
 /* Like strcpy but can copy overlapping strings. */
 void FAST_FUNC overlapping_strcpy(char *dst, const char *src)
 {
-       while ((*dst = *src) != '\0') {
-               dst++;
-               src++;
+       /* Cheap optimization for dst == src case -
+        * better to have it here than in many callers.
+        */
+       if (dst != src) {
+               while ((*dst = *src) != '\0') {
+                       dst++;
+                       src++;
+               }
        }
 }