Author: markj Date: Thu Jun 6 03:03:54 2019 New Revision: 348720 URL: https://svnweb.freebsd.org/changeset/base/348720
Log: MFC r348431: elfcopy: Optimize for insertions at the end of the section list. PR: 234949 Modified: stable/12/contrib/elftoolchain/elfcopy/elfcopy.h stable/12/contrib/elftoolchain/elfcopy/sections.c Directory Properties: stable/12/ (props changed) Modified: stable/12/contrib/elftoolchain/elfcopy/elfcopy.h ============================================================================== --- stable/12/contrib/elftoolchain/elfcopy/elfcopy.h Thu Jun 6 03:02:43 2019 (r348719) +++ stable/12/contrib/elftoolchain/elfcopy/elfcopy.h Thu Jun 6 03:03:54 2019 (r348720) @@ -138,6 +138,8 @@ struct section { TAILQ_ENTRY(section) sec_list; /* next section */ }; +TAILQ_HEAD(sectionlist, section); + /* Internal data structure for segments. */ struct segment { uint64_t vaddr; /* virtual addr (VMA) */ Modified: stable/12/contrib/elftoolchain/elfcopy/sections.c ============================================================================== --- stable/12/contrib/elftoolchain/elfcopy/sections.c Thu Jun 6 03:02:43 2019 (r348719) +++ stable/12/contrib/elftoolchain/elfcopy/sections.c Thu Jun 6 03:03:54 2019 (r348720) @@ -314,18 +314,18 @@ insert_to_sec_list(struct elfcopy *ecp, struct section { struct section *s; - if (!tail) { + if (tail || TAILQ_EMPTY(&ecp->v_sec) || + TAILQ_LAST(&ecp->v_sec, sectionlist)->off <= sec->off) { + TAILQ_INSERT_TAIL(&ecp->v_sec, sec, sec_list); + } else { TAILQ_FOREACH(s, &ecp->v_sec, sec_list) { if (sec->off < s->off) { TAILQ_INSERT_BEFORE(s, sec, sec_list); - goto inc_nos; + break; } } } - TAILQ_INSERT_TAIL(&ecp->v_sec, sec, sec_list); - -inc_nos: if (sec->pseudo == 0) ecp->nos++; } _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"