Patchwork [8/9] Use memcpy in minimal_symbol_reader::install

login
register
mail settings
Submitter Tom Tromey
Date March 7, 2019, 8:57 p.m.
Message ID <20190307205709.21919-9-tom@tromey.com>
Download mbox | patch
Permalink /patch/31778/
State New
Headers show

Comments

Tom Tromey - March 7, 2019, 8:57 p.m.
minimal_symbol_reader::install copies minsyms from the msym_bunch
objects into the allocated memory.  It seemed better to me to do this
via memcpy, as that is frequently optimized in libc.

gdb/ChangeLog
2019-03-07  Tom Tromey  <tom@tromey.com>

	* minsyms.c (minimal_symbol_reader::install): Use memcpy.
---
 gdb/ChangeLog | 4 ++++
 gdb/minsyms.c | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

Patch

diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index f86105db7ee..4f3c929cd72 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1330,7 +1330,6 @@  build_minimal_symbol_hash_tables (struct objfile *objfile)
 void
 minimal_symbol_reader::install ()
 {
-  int bindex;
   int mcount;
   struct msym_bunch *bunch;
   struct minimal_symbol *msymbols;
@@ -1377,8 +1376,9 @@  minimal_symbol_reader::install ()
 
       for (bunch = m_msym_bunch; bunch != NULL; bunch = bunch->next)
 	{
-	  for (bindex = 0; bindex < m_msym_bunch_index; bindex++, mcount++)
-	    msymbols[mcount] = bunch->contents[bindex];
+	  memcpy (&msymbols[mcount], &bunch->contents[0],
+		  m_msym_bunch_index * sizeof (struct minimal_symbol));
+	  mcount += m_msym_bunch_index;
 	  m_msym_bunch_index = BUNCH_SIZE;
 	}