[llvm] 5361304 - [llvm-objcopy] Use SmallVector to make some structs smaller. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 22:28:37 PDT 2024
Author: Fangrui Song
Date: 2024-03-12T22:28:32-07:00
New Revision: 53613044ddf1bab186cde8d687f7f41bc0b1f9b1
URL: https://github.com/llvm/llvm-project/commit/53613044ddf1bab186cde8d687f7f41bc0b1f9b1
DIFF: https://github.com/llvm/llvm-project/commit/53613044ddf1bab186cde8d687f7f41bc0b1f9b1.diff
LOG: [llvm-objcopy] Use SmallVector to make some structs smaller. NFC
Added:
Modified:
llvm/include/llvm/ObjCopy/CommonConfig.h
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ObjCopy/CommonConfig.h b/llvm/include/llvm/ObjCopy/CommonConfig.h
index 383395941475a4..3f894b0cd9587a 100644
--- a/llvm/include/llvm/ObjCopy/CommonConfig.h
+++ b/llvm/include/llvm/ObjCopy/CommonConfig.h
@@ -22,7 +22,6 @@
// Necessary for llvm::DebugCompressionType::None
#include "llvm/Target/TargetOptions.h"
#include <optional>
-#include <vector>
namespace llvm {
namespace objcopy {
@@ -126,8 +125,8 @@ class NameOrPattern {
// provided for that option.
class NameMatcher {
DenseSet<CachedHashStringRef> PosNames;
- std::vector<NameOrPattern> PosPatterns;
- std::vector<NameOrPattern> NegMatchers;
+ SmallVector<NameOrPattern, 0> PosPatterns;
+ SmallVector<NameOrPattern, 0> NegMatchers;
public:
Error addMatcher(Expected<NameOrPattern> Matcher) {
@@ -179,8 +178,8 @@ struct NewSymbolInfo {
StringRef SymbolName;
StringRef SectionName;
uint64_t Value = 0;
- std::vector<SymbolFlag> Flags;
- std::vector<StringRef> BeforeSyms;
+ SmallVector<SymbolFlag, 0> Flags;
+ SmallVector<StringRef, 0> BeforeSyms;
};
// Specify section name and section body for newly added or updated section.
@@ -218,9 +217,9 @@ struct CommonConfig {
DiscardType DiscardMode = DiscardType::None;
// Repeated options
- std::vector<NewSectionInfo> AddSection;
- std::vector<StringRef> DumpSection;
- std::vector<NewSectionInfo> UpdateSection;
+ SmallVector<NewSectionInfo, 0> AddSection;
+ SmallVector<StringRef, 0> DumpSection;
+ SmallVector<NewSectionInfo, 0> UpdateSection;
// Section matchers
NameMatcher KeepSection;
@@ -244,7 +243,7 @@ struct CommonConfig {
StringMap<StringRef> SymbolsToRename;
// Symbol info specified by --add-symbol option.
- std::vector<NewSymbolInfo> SymbolsToAdd;
+ SmallVector<NewSymbolInfo, 0> SymbolsToAdd;
// Boolean options
bool DeterministicArchives = true;
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
index 6318578b110048..c5c7cc254d7920 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -528,7 +528,7 @@ static Expected<NewSymbolInfo> parseNewSymbolInfo(StringRef FlagValue) {
// ArgValue, loads data from the file, and stores section name and data
// into the vector of new sections \p NewSections.
static Error loadNewSectionData(StringRef ArgValue, StringRef OptionName,
- std::vector<NewSectionInfo> &NewSections) {
+ SmallVector<NewSectionInfo, 0> &NewSections) {
if (!ArgValue.contains('='))
return createStringError(errc::invalid_argument,
"bad format for " + OptionName + ": missing '='");
More information about the llvm-commits
mailing list