lkml.org 
[lkml]   [2010]   [Jul]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectSmall perf optimization
Before this bad practice of using arrays of string pointers to constant
strings further spreads let's fix it. With this change not only is the
entire data associated with the arrays read-only, it also replaces a
memory lookup with a trivial arithmetic operation. The result is
a smaller and faster binary.


Signed-off-by: Ulrich Drepper <drepper@redhat.com>


diff --git a/tools/perf/arch/sparc/util/dwarf-regs.c b/tools/perf/arch/sparc/util/dwarf-regs.c
index 0ab8848..17f193e 100644
--- a/tools/perf/arch/sparc/util/dwarf-regs.c
+++ b/tools/perf/arch/sparc/util/dwarf-regs.c
@@ -14,7 +14,7 @@

#define SPARC_MAX_REGS 96

-const char *sparc_regs_table[SPARC_MAX_REGS] = {
+static const char sparc_regs_table[SPARC_MAX_REGS][5] = {
"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7",
"%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7",
"%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7",
diff --git a/tools/perf/arch/x86/util/dwarf-regs.c b/tools/perf/arch/x86/util/dwarf-regs.c
index a794d30..fe5ef0f 100644
--- a/tools/perf/arch/x86/util/dwarf-regs.c
+++ b/tools/perf/arch/x86/util/dwarf-regs.c
@@ -28,7 +28,7 @@
*/

#define X86_32_MAX_REGS 8
-const char *x86_32_regs_table[X86_32_MAX_REGS] = {
+static const char x86_32_regs_table[X86_32_MAX_REGS][7] = {
"%ax",
"%cx",
"%dx",
@@ -40,7 +40,7 @@ const char *x86_32_regs_table[X86_32_MAX_REGS] = {
};

#define X86_64_MAX_REGS 16
-const char *x86_64_regs_table[X86_64_MAX_REGS] = {
+static const char x86_64_regs_table[X86_64_MAX_REGS][5] = {
"%ax",
"%dx",
"%cx",

\
 
 \ /
  Last update: 2010-07-22 18:15    [W:0.304 / U:0.732 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site