Minor lib/gdbserv-output optimization

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Minor lib/gdbserv-output optimization

Kevin Buettner
While comparing Red Hat's internal RDA sources to the public ones, I came
across this old change by Michael Snyder.

Committed.

Kevin

2009-11-06  Kevin Buettner  <[hidden email]>

        From Michael Snyder (circa 2004):
        * lib/gdbserv-output.c (gdbserv_output_string_as_bytes):
        Pull strlen out of loop for optimization.
        (gdbserv_output_string): Ditto.
       
Index: lib/gdbserv-output.c
===================================================================
RCS file: /cvs/src/src/rda/lib/gdbserv-output.c,v
retrieving revision 1.2
diff -u -p -r1.2 gdbserv-output.c
--- lib/gdbserv-output.c 24 Sep 2004 21:18:59 -0000 1.2
+++ lib/gdbserv-output.c 7 Nov 2009 05:19:35 -0000
@@ -57,7 +57,9 @@ void
 gdbserv_output_string_as_bytes (struct gdbserv *gdbserv, const char *packet)
 {
   int i;
-  for (i = 0; i < strlen (packet); i++)
+  int len = strlen (packet);
+
+  for (i = 0; i < len; i++)
     {
       gdbserv_output_byte (gdbserv, packet[i]);
     }
@@ -67,7 +69,9 @@ void
 gdbserv_output_string (struct gdbserv *gdbserv, const char *packet)
 {
   int i;
-  for (i = 0; i < strlen (packet); i++)
+  int len = strlen (packet);
+
+  for (i = 0; i < len; i++)
     gdbserv_output_char (gdbserv, packet[i]);
 }