]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgfortran/generated/eoshift1_16.c
Update copyright years.
[thirdparty/gcc.git] / libgfortran / generated / eoshift1_16.c
index 9ba5fda017fa6bbfb3a7cd7ba831922c96de42ac..27b552ddb18bcd4de9074b36adcae7b39da2cebd 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of the EOSHIFT intrinsic
-   Copyright (C) 2002-2016 Free Software Foundation, Inc.
+   Copyright (C) 2002-2020 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
 This file is part of the GNU Fortran runtime library (libgfortran).
@@ -84,11 +84,9 @@ eoshift1 (gfc_array_char * const restrict ret,
   arraysize = size0 ((array_t *) array);
   if (ret->base_addr == NULL)
     {
-      int i;
-
       ret->offset = 0;
-      ret->dtype = array->dtype;
-      for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+      GFC_DTYPE_COPY(ret,array);
+      for (index_type i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
         {
          index_type ub, str;
 
@@ -183,12 +181,23 @@ eoshift1 (gfc_array_char * const restrict ret,
           src = sptr;
           dest = &rptr[delta * roffset];
         }
-      for (n = 0; n < len - delta; n++)
-        {
-          memcpy (dest, src, size);
-          dest += roffset;
-          src += soffset;
-        }
+
+      /* If the elements are contiguous, perform a single block move.  */
+      if (soffset == size && roffset == size)
+       {
+         size_t chunk = size * (len - delta);
+         memcpy (dest, src, chunk);
+         dest += chunk;
+       }
+      else
+       {
+         for (n = 0; n < len - delta; n++)
+           {
+             memcpy (dest, src, size);
+             dest += roffset;
+             src += soffset;
+           }
+       }
       if (sh < 0)
         dest = rptr;
       n = delta;