Improve the offset, length, and end getters in AstNodeImpl
While this does improve the performance of these getters (by about 5%) the purpose of this CL is just to clean up the implementation of them. It bothers my that they (especially `end`) are using such an indirect way of computing their values. Change-Id: I384890a9adc108c4c67b906864201edee9aa8598 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426400 Auto-Submit: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
ba40d9bece
commit
f01486a8e4
@@ -1053,17 +1053,13 @@ sealed class AstNodeImpl implements AstNode {
|
||||
_childEntities.syntacticEntities;
|
||||
|
||||
@override
|
||||
int get end => offset + length;
|
||||
int get end => endToken.end;
|
||||
|
||||
@override
|
||||
bool get isSynthetic => false;
|
||||
|
||||
@override
|
||||
int get length {
|
||||
var beginToken = this.beginToken;
|
||||
var endToken = this.endToken;
|
||||
return endToken.offset + endToken.length - beginToken.offset;
|
||||
}
|
||||
int get length => end - offset;
|
||||
|
||||
/// The properties (tokens and nodes) of this node, with names, in the order
|
||||
/// in which these entities should normally appear, not necessarily in the
|
||||
@@ -1071,10 +1067,7 @@ sealed class AstNodeImpl implements AstNode {
|
||||
Iterable<ChildEntity> get namedChildEntities => _childEntities.entities;
|
||||
|
||||
@override
|
||||
int get offset {
|
||||
var beginToken = this.beginToken;
|
||||
return beginToken.offset;
|
||||
}
|
||||
int get offset => beginToken.offset;
|
||||
|
||||
@override
|
||||
AstNode? get parent => _parent;
|
||||
|
||||
Reference in New Issue
Block a user