Improve parse_dot_or_call_expr_with
.
Avoid all the extra work in the very common case where `attrs` is empty.
This commit is contained in:
parent
b38106b6d8
commit
c768617f6f
1 changed files with 11 additions and 6 deletions
|
@ -944,7 +944,11 @@ impl<'a> Parser<'a> {
|
||||||
// Stitch the list of outer attributes onto the return value.
|
// Stitch the list of outer attributes onto the return value.
|
||||||
// A little bit ugly, but the best way given the current code
|
// A little bit ugly, but the best way given the current code
|
||||||
// structure
|
// structure
|
||||||
self.parse_dot_or_call_expr_with_(e0, lo).map(|expr| {
|
let res = self.parse_dot_or_call_expr_with_(e0, lo);
|
||||||
|
if attrs.is_empty() {
|
||||||
|
res
|
||||||
|
} else {
|
||||||
|
res.map(|expr| {
|
||||||
expr.map(|mut expr| {
|
expr.map(|mut expr| {
|
||||||
attrs.extend(expr.attrs);
|
attrs.extend(expr.attrs);
|
||||||
expr.attrs = attrs;
|
expr.attrs = attrs;
|
||||||
|
@ -952,6 +956,7 @@ impl<'a> Parser<'a> {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_dot_or_call_expr_with_(&mut self, mut e: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
|
fn parse_dot_or_call_expr_with_(&mut self, mut e: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
|
||||||
loop {
|
loop {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue