mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 22:02:51 +01:00
Use llvm::ListSeparator for simpler separators (#671)
I was looking for something like this, I think it's a straightforward simplification for code. Internally, it handles skipping the separator on the first print. See the bottom of: https://llvm.org/doxygen/StringExtras_8h_source.html
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "executable_semantics/interpreter/heap.h"
|
||||
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
auto Heap::AllocateValue(const Value* v) -> Address {
|
||||
@@ -48,9 +50,10 @@ void Heap::Deallocate(const Address& address) {
|
||||
}
|
||||
|
||||
void Heap::Print(llvm::raw_ostream& out) const {
|
||||
llvm::ListSeparator sep;
|
||||
for (size_t i = 0; i < values_.size(); ++i) {
|
||||
out << sep;
|
||||
PrintAddress(Address(i), out);
|
||||
out << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user