ast: Simplify SizeExprToString()
Clean up as recommended in review:
https://dawn-review.googlesource.com/c/tint/+/66380/6/src/ast/array.cc#34
Change-Id: I70d66ab552de4a4a4d869aedd2f3c3d9f59d2712
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/66603
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/ast/array.cc b/src/ast/array.cc
index c582805..826efd2 100644
--- a/src/ast/array.cc
+++ b/src/ast/array.cc
@@ -26,12 +26,9 @@
namespace {
// Returns the string representation of an array size expression.
std::string SizeExprToString(const ast::Expression* size,
- const SymbolTable* symbols = nullptr) {
+ const SymbolTable& symbols) {
if (auto* ident = size->As<ast::IdentifierExpression>()) {
- if (symbols) {
- return symbols->NameFor(ident->symbol);
- }
- return "<unknown>";
+ return symbols.NameFor(ident->symbol);
}
if (auto* scalar = size->As<ast::ScalarConstructorExpression>()) {
auto* literal = scalar->literal->As<ast::IntLiteral>();
@@ -65,7 +62,7 @@
}
out << "array<" << type->FriendlyName(symbols);
if (!IsRuntimeArray()) {
- out << ", " << SizeExprToString(count, &symbols);
+ out << ", " << SizeExprToString(count, symbols);
}
out << ">";
return out.str();