Skip to content

Commit 94128c9

Browse files
committed
fixup! rename API; move notifyInsertion to after new data was written
1 parent 8526be4 commit 94128c9

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

libcxxabi/src/demangle/Utility.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ class OutputBuffer {
9696
/// Called when we write to this object anywhere other than the end.
9797
virtual void notifyInsertion(size_t /*Position*/, size_t /*Count*/) {}
9898

99-
/// Called when we reset the \c CurrentPosition of this object.
100-
virtual void notifyPositionChanged(size_t /*OldPos*/, size_t /*NewPos*/) {}
99+
/// Called when we make the \c CurrentPosition of this object smaller.
100+
virtual void notifyDeletion(size_t /*OldPos*/, size_t /*NewPos*/) {}
101101

102102
/// If a ParameterPackExpansion (or similar type) is encountered, the offset
103103
/// into the pack that we're currently printing.
@@ -137,13 +137,13 @@ class OutputBuffer {
137137
OutputBuffer &prepend(std::string_view R) {
138138
size_t Size = R.size();
139139

140-
notifyInsertion(/*Position=*/0, /*Count=*/Size);
141-
142140
grow(Size);
143141
std::memmove(Buffer + Size, Buffer, CurrentPosition);
144142
std::memcpy(Buffer, &*R.begin(), Size);
145143
CurrentPosition += Size;
146144

145+
notifyInsertion(/*Position=*/0, /*Count=*/Size);
146+
147147
return *this;
148148
}
149149

@@ -180,17 +180,17 @@ class OutputBuffer {
180180
if (N == 0)
181181
return;
182182

183-
notifyInsertion(Pos, N);
184-
185183
grow(N);
186184
std::memmove(Buffer + Pos + N, Buffer + Pos, CurrentPosition - Pos);
187185
std::memcpy(Buffer + Pos, S, N);
188186
CurrentPosition += N;
187+
188+
notifyInsertion(Pos, N);
189189
}
190190

191191
size_t getCurrentPosition() const { return CurrentPosition; }
192192
void setCurrentPosition(size_t NewPos) {
193-
notifyPositionChanged(CurrentPosition, NewPos);
193+
notifyDeletion(CurrentPosition, NewPos);
194194
CurrentPosition = NewPos;
195195
}
196196

llvm/include/llvm/Demangle/Utility.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ class OutputBuffer {
9696
/// Called when we write to this object anywhere other than the end.
9797
virtual void notifyInsertion(size_t /*Position*/, size_t /*Count*/) {}
9898

99-
/// Called when we reset the \c CurrentPosition of this object.
100-
virtual void notifyPositionChanged(size_t /*OldPos*/, size_t /*NewPos*/) {}
99+
/// Called when we make the \c CurrentPosition of this object smaller.
100+
virtual void notifyDeletion(size_t /*OldPos*/, size_t /*NewPos*/) {}
101101

102102
/// If a ParameterPackExpansion (or similar type) is encountered, the offset
103103
/// into the pack that we're currently printing.
@@ -137,13 +137,13 @@ class OutputBuffer {
137137
OutputBuffer &prepend(std::string_view R) {
138138
size_t Size = R.size();
139139

140-
notifyInsertion(/*Position=*/0, /*Count=*/Size);
141-
142140
grow(Size);
143141
std::memmove(Buffer + Size, Buffer, CurrentPosition);
144142
std::memcpy(Buffer, &*R.begin(), Size);
145143
CurrentPosition += Size;
146144

145+
notifyInsertion(/*Position=*/0, /*Count=*/Size);
146+
147147
return *this;
148148
}
149149

@@ -180,17 +180,17 @@ class OutputBuffer {
180180
if (N == 0)
181181
return;
182182

183-
notifyInsertion(Pos, N);
184-
185183
grow(N);
186184
std::memmove(Buffer + Pos + N, Buffer + Pos, CurrentPosition - Pos);
187185
std::memcpy(Buffer + Pos, S, N);
188186
CurrentPosition += N;
187+
188+
notifyInsertion(Pos, N);
189189
}
190190

191191
size_t getCurrentPosition() const { return CurrentPosition; }
192192
void setCurrentPosition(size_t NewPos) {
193-
notifyPositionChanged(CurrentPosition, NewPos);
193+
notifyDeletion(CurrentPosition, NewPos);
194194
CurrentPosition = NewPos;
195195
}
196196

llvm/unittests/Demangle/OutputBufferTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ TEST(OutputBufferTest, Notifications) {
9999
size_t Inserted = 0;
100100
size_t LatestPos = 0;
101101

102-
void notifyPositionChanged(size_t OldPos, size_t NewPos) override {
102+
void notifyDeletion(size_t OldPos, size_t NewPos) override {
103103
LatestPos = NewPos;
104104
}
105105

0 commit comments

Comments
 (0)