Skip to content

Commit 239e255

Browse files
authored
refactor: remove obsolete format string workaround (#448)
Remove workaround for old Clang/libc++ bug where "<{}>" in format strings was incorrectly parsed. Modern compilers handle this correctly. Changes: - Simplify ListType::ToString() to use direct format string - Simplify MapType::ToString() to use direct format string - Remove XXX comments about the workaround The existing tests will verify this works correctly on current compilers.
1 parent 8926246 commit 239e255

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/iceberg/type.cc

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,7 @@ ListType::ListType(int32_t field_id, std::shared_ptr<Type> type, bool optional)
150150
: element_(field_id, std::string(kElementName), std::move(type), optional) {}
151151

152152
TypeId ListType::type_id() const { return kTypeId; }
153-
std::string ListType::ToString() const {
154-
// XXX: work around Clang/libc++: "<{}>" in a format string appears to get
155-
// parsed as {<>} or something; split up the format string to avoid that
156-
std::string repr = "list<";
157-
std::format_to(std::back_inserter(repr), "{}", element_);
158-
repr += ">";
159-
return repr;
160-
}
153+
std::string ListType::ToString() const { return std::format("list<{}>", element_); }
161154

162155
std::span<const SchemaField> ListType::fields() const { return {&element_, 1}; }
163156
Result<std::optional<NestedType::SchemaFieldConstRef>> ListType::GetFieldById(
@@ -213,13 +206,7 @@ const SchemaField& MapType::value() const { return fields_[1]; }
213206
TypeId MapType::type_id() const { return kTypeId; }
214207

215208
std::string MapType::ToString() const {
216-
// XXX: work around Clang/libc++: "<{}>" in a format string appears to get
217-
// parsed as {<>} or something; split up the format string to avoid that
218-
std::string repr = "map<";
219-
220-
std::format_to(std::back_inserter(repr), "{}: {}", key(), value());
221-
repr += ">";
222-
return repr;
209+
return std::format("map<{}: {}>", key(), value());
223210
}
224211

225212
std::span<const SchemaField> MapType::fields() const { return fields_; }

0 commit comments

Comments
 (0)