This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Remove small copy optimization from xsputn


Let the compiler and/or the optimized mempcpy implementation take care
of this.

The hand-written byte-at-a-time loop for counts <= 20 actually showed
up in profiles for me.

This slow loop triggers for a reasonably important case, since PADSIZE
is 16.

Any objections?

2012-03-28  David S. Miller  <davem@davemloft.net>

	* libio/fileops.c (_IO_new_file_xsputn): Don't try to optimize
	small copies by hand.

diff --git a/libio/fileops.c b/libio/fileops.c
index 95e09b4..a2e8dac 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -1341,24 +1341,13 @@ _IO_new_file_xsputn (f, data, n)
     {
       if (count > to_do)
 	count = to_do;
-      if (count > 20)
-	{
 #ifdef _LIBC
-	  f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
+      f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
 #else
-	  memcpy (f->_IO_write_ptr, s, count);
-	  f->_IO_write_ptr += count;
+      memcpy (f->_IO_write_ptr, s, count);
+      f->_IO_write_ptr += count;
 #endif
-	  s += count;
-	}
-      else
-	{
-	  register char *p = f->_IO_write_ptr;
-	  register int i = (int) count;
-	  while (--i >= 0)
-	    *p++ = *s++;
-	  f->_IO_write_ptr = p;
-	}
+      s += count;
       to_do -= count;
     }
   if (to_do + must_flush > 0)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]