Skip to content

Commit a406f34

Browse files
committed
Simplify code.
1 parent 06aec44 commit a406f34

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

source/slang/slang-check-decl.cpp

+4-12
Original file line numberDiff line numberDiff line change
@@ -2040,21 +2040,13 @@ namespace Slang
20402040
}
20412041
}
20422042

2043-
std::optional<TypeTag> varTypeTags;
2044-
auto getVarTypeTags = [&]()
2045-
{
2046-
if (!varTypeTags.has_value())
2047-
{
2048-
varTypeTags = getTypeTags(varDecl->getType());
2049-
}
2050-
return varTypeTags.value();
2051-
};
2043+
TypeTag varTypeTags = getTypeTags(varDecl->getType());
20522044
auto parentDecl = as<AggTypeDecl>(getParentDecl(varDecl));
20532045
if (parentDecl)
20542046
{
2055-
parentDecl->addTag(getVarTypeTags());
2047+
parentDecl->addTag(varTypeTags);
20562048
auto unsizedMask = (int)TypeTag::Unsized;
2057-
bool isUnknownSize = (((int)getVarTypeTags() & unsizedMask) != 0);
2049+
bool isUnknownSize = (((int)varTypeTags & unsizedMask) != 0);
20582050
if (isUnknownSize)
20592051
{
20602052
// Unsized decl must appear as the last member of the struct.
@@ -2079,7 +2071,7 @@ namespace Slang
20792071
(!parentDecl || isEffectivelyStatic(varDecl));
20802072
if (isGlobalOrLocalVar)
20812073
{
2082-
bool isUnsized = (((int)getVarTypeTags() & (int)TypeTag::Unsized) != 0);
2074+
bool isUnsized = (((int)varTypeTags & (int)TypeTag::Unsized) != 0);
20832075
if (isUnsized)
20842076
{
20852077
getSink()->diagnose(varDecl, Diagnostics::varCannotBeUnsized);

0 commit comments

Comments
 (0)