Skip to content

Commit 996e94d

Browse files
authored
Merge pull request #19790 from rjmccall/read-optimizations
Optimize read accessors to just borrow yielded storage references
2 parents b7ee2ba + 6f1fd82 commit 996e94d

File tree

10 files changed

+417
-73
lines changed

10 files changed

+417
-73
lines changed

lib/Parse/ParseStmt.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,8 @@ ParserResult<Stmt> Parser::parseStmtYield(SourceLoc tryLoc) {
828828
.fixItRemoveChars(tryLoc, yieldLoc);
829829
}
830830

831+
SyntaxParsingContext YieldsCtxt(SyntaxContext, SyntaxKind::YieldList);
832+
831833
SmallVector<Identifier, 4> yieldLabels;
832834
SmallVector<SourceLoc, 4> yieldLabelLocs;
833835
Expr *trailingClosure = nullptr;
@@ -839,7 +841,7 @@ ParserResult<Stmt> Parser::parseStmtYield(SourceLoc tryLoc) {
839841
yields, yieldLabels, yieldLabelLocs,
840842
rpLoc,
841843
trailingClosure,
842-
SyntaxKind::YieldStmt);
844+
SyntaxKind::ExprList);
843845
assert(trailingClosure == nullptr);
844846
assert(yieldLabels.empty());
845847
assert(yieldLabelLocs.empty());

lib/SILGen/ArgumentSource.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ class ArgumentSource {
196196
return Storage.get<LValueStorage>(StoredKind).Loc;
197197
}
198198

199+
Expr *peekExpr() & {
200+
return Storage.get<Expr*>(StoredKind);
201+
}
202+
199203
/// Given that this source is an expression, extract and clear
200204
/// that expression.
201205
Expr *asKnownExpr() && {

0 commit comments

Comments
 (0)