-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WGSL] Use String instead of StringView for Identifiers #8697
[WGSL] Use String instead of StringView for Identifiers #8697
Conversation
EWS run on previous version of this PR (hash 532faa5) |
532faa5
to
acb2d07
Compare
EWS run on previous version of this PR (hash acb2d07) |
@@ -33,17 +33,17 @@ class BuiltinAttribute final : public Attribute { | |||
WTF_MAKE_FAST_ALLOCATED; | |||
|
|||
public: | |||
BuiltinAttribute(SourceSpan span, StringView name) | |||
BuiltinAttribute(SourceSpan span, String name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're doing a double copy here; surely you want the parameter to be const String&
? Or you could keep the parameter a StringView
but still change the parameter to String m_name
like you're doing below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, I didn't worry too much since the underlying string isn't being copied anyway, so it's equivalent to the StringView code (right?). But in any case, no downside in making it const String&
.
@@ -66,7 +66,7 @@ class FunctionDecl final : public Decl { | |||
public: | |||
using List = UniqueRefVector<FunctionDecl>; | |||
|
|||
FunctionDecl(SourceSpan sourceSpan, StringView name, Parameter::List&& parameters, std::unique_ptr<TypeDecl>&& returnType, CompoundStatement&& body, Attribute::List&& attributes, Attribute::List&& returnAttributes) | |||
FunctionDecl(SourceSpan sourceSpan, String name, Parameter::List&& parameters, std::unique_ptr<TypeDecl>&& returnType, CompoundStatement&& body, Attribute::List&& attributes, Attribute::List&& returnAttributes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
|
||
namespace WGSL::AST { | ||
|
||
class IdentifierExpression final : public Expression { | ||
WTF_MAKE_FAST_ALLOCATED; | ||
|
||
public: | ||
IdentifierExpression(SourceSpan span, StringView identifier) | ||
IdentifierExpression(SourceSpan span, String identifier) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto, and ditto elsewhere too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with Myles nit fixed.
acb2d07
to
82cd107
Compare
EWS run on previous version of this PR (hash 82cd107) |
@@ -41,7 +41,7 @@ class Parameter final : public Node { | |||
public: | |||
using List = UniqueRefVector<Parameter>; | |||
|
|||
Parameter(SourceSpan span, StringView name, UniqueRef<TypeDecl>&& type, Attribute::List&& attributes) | |||
Parameter(SourceSpan span, const String& name, UniqueRef<TypeDecl>&& type, Attribute::List&& attributes) | |||
: Node(span) | |||
, m_name(WTFMove(name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, forgot this WTFMove
here and now name
is a constant. So weird that local builds aren't failing though...
82cd107
to
6faee3c
Compare
EWS run on current version of this PR (hash 6faee3c) |
https://bugs.webkit.org/show_bug.cgi?id=250680 <rdar://problem/104299588> Reviewed by Myles C. Maxfield. There should be no extra cost if we create the string without copying and it allows us to use runtime-generated strings which will be necessary soon. * Source/WebGPU/WGSL/AST/ASTArrayAccess.h: * Source/WebGPU/WGSL/AST/ASTAttribute.h: * Source/WebGPU/WGSL/AST/ASTBuiltinAttribute.h: * Source/WebGPU/WGSL/AST/ASTFunctionDecl.h: * Source/WebGPU/WGSL/AST/ASTGlobalDirective.h: (WGSL::AST::GlobalDirective::GlobalDirective): (WGSL::AST::GlobalDirective::name const): * Source/WebGPU/WGSL/AST/ASTIdentifierExpression.h: * Source/WebGPU/WGSL/AST/ASTLocationAttribute.h: * Source/WebGPU/WGSL/AST/ASTStructureAccess.h: * Source/WebGPU/WGSL/AST/ASTStructureDecl.h: * Source/WebGPU/WGSL/AST/ASTTypeDecl.h: (WGSL::AST::ParameterizedType::stringToKind): (WGSL::AST::ParameterizedType::stringViewToKind): Deleted. * Source/WebGPU/WGSL/AST/ASTVariableDecl.h: * Source/WebGPU/WGSL/Lexer.cpp: (WGSL::Lexer<T>::lex): * Source/WebGPU/WGSL/Lexer.h: (WGSL::Lexer::makeIdentifierToken): * Source/WebGPU/WGSL/Parser.cpp: (WGSL::Parser<Lexer>::parseTypeDecl): (WGSL::Parser<Lexer>::parseTypeDeclAfterIdentifier): * Source/WebGPU/WGSL/ParserPrivate.h: * Source/WebGPU/WGSL/Token.h: (WGSL::Token::Token): (WGSL::Token::operator=): (WGSL::Token::~Token): Canonical link: https://commits.webkit.org/259044@main
6faee3c
to
b965bbc
Compare
Committed 259044@main (b965bbc): https://commits.webkit.org/259044@main Reviewed commits have been landed. Closing PR #8697 and removing active labels. |
b965bbc
6faee3c
π§ͺ ios-wk2