From 04f792de9f4977223b1fbd31770167517ae8d727 Mon Sep 17 00:00:00 2001 From: James Price Date: Thu, 8 Dec 2022 19:01:17 +0000 Subject: [PATCH] tint/transform: Use InsertFront to add attribute This is simpler than reconstructing the attribute list and manually cloning the struct member. Change-Id: I3d0bd4039030b47e53ce618d9de7ee572b9698f1 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113422 Reviewed-by: Ben Clayton Kokoro: Kokoro --- src/tint/transform/packed_vec3.cc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/tint/transform/packed_vec3.cc b/src/tint/transform/packed_vec3.cc index 2aba94d98f..af0c219022 100644 --- a/src/tint/transform/packed_vec3.cc +++ b/src/tint/transform/packed_vec3.cc @@ -56,16 +56,9 @@ struct PackedVec3::State { members.Add(member); // Apply the PackedVec3::Attribute to the member - auto* member_decl = member->Declaration(); - auto name = ctx.Clone(member->Name()); - auto* type = ctx.Clone(member_decl->type); - utils::Vector attrs{ - b.ASTNodes().Create(b.ID(), b.AllocateNodeID()), - }; - for (auto* attr : member_decl->attributes) { - attrs.Push(ctx.Clone(attr)); - } - ctx.Replace(member_decl, b.Member(name, type, std::move(attrs))); + ctx.InsertFront( + member->Declaration()->attributes, + b.ASTNodes().Create(b.ID(), b.AllocateNodeID())); } } }