Skip to content

Commit

Permalink
[llvm-objcopy] Use SmallVector to make some structs smaller. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Mar 13, 2024
1 parent deebf6b commit 5361304
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions llvm/include/llvm/ObjCopy/CommonConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
// Necessary for llvm::DebugCompressionType::None
#include "llvm/Target/TargetOptions.h"
#include <optional>
#include <vector>

namespace llvm {
namespace objcopy {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 '='");
Expand Down

0 comments on commit 5361304

Please sign in to comment.