mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-02 09:33:59 +00:00
StringToOffsetTable: Allow uniquing the first element, add an option to skip appending a terminating null.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151983 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e19ead0f24
commit
02ee75393f
@ -26,16 +26,17 @@ class StringToOffsetTable {
|
||||
std::string AggregateString;
|
||||
public:
|
||||
|
||||
unsigned GetOrAddStringOffset(StringRef Str) {
|
||||
unsigned &Entry = StringOffset[Str];
|
||||
if (Entry == 0) {
|
||||
unsigned GetOrAddStringOffset(StringRef Str, bool appendZero = true) {
|
||||
StringMapEntry<unsigned> &Entry = StringOffset.GetOrCreateValue(Str, -1U);
|
||||
if (Entry.getValue() == -1U) {
|
||||
// Add the string to the aggregate if this is the first time found.
|
||||
Entry = AggregateString.size();
|
||||
Entry.setValue(AggregateString.size());
|
||||
AggregateString.append(Str.begin(), Str.end());
|
||||
AggregateString += '\0';
|
||||
if (appendZero)
|
||||
AggregateString += '\0';
|
||||
}
|
||||
|
||||
return Entry;
|
||||
return Entry.getValue();
|
||||
}
|
||||
|
||||
void EmitString(raw_ostream &O) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user