* Small perf optimization
@ 2010-07-22 16:11 Ulrich Drepper
2010-07-22 16:21 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: Ulrich Drepper @ 2010-07-22 16:11 UTC (permalink / raw)
To: a.p.zijlstra, acme, davem, imunsie, linux-kernel, mhiramat, mingo,
paulus
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",
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: Small perf optimization
2010-07-22 16:11 Small perf optimization Ulrich Drepper
@ 2010-07-22 16:21 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-07-22 16:21 UTC (permalink / raw)
To: Ulrich Drepper
Cc: a.p.zijlstra, davem, imunsie, linux-kernel, mhiramat, mingo,
paulus
Em Thu, Jul 22, 2010 at 12:11:49PM -0400, Ulrich Drepper escreveu:
> 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>
Thanks, applying to perf/core (i.e. for 2.6.36).
- Arnaldo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-22 16:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-22 16:11 Small perf optimization Ulrich Drepper
2010-07-22 16:21 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.