-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix performance regression from selector spans (#1916)
- Loading branch information
Showing
7 changed files
with
86 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2023 Google LLC. Use of this source code is governed by an | ||
// MIT-style license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
import 'package:source_span/source_span.dart'; | ||
|
||
/// A wrapper for [FileSpan] that allows an expensive creation process to be | ||
/// deferred until the span is actually needed. | ||
class LazyFileSpan implements FileSpan { | ||
/// The function that creates the underlying span. | ||
final FileSpan Function() _builder; | ||
|
||
/// The underlying span this wraps, which is created the first time this | ||
/// getter is referenced. | ||
FileSpan get span => _span ??= _builder(); | ||
FileSpan? _span; | ||
|
||
/// Creates a new [LazyFileSpan] that defers calling [builder] until the | ||
/// underlying span is needed. | ||
LazyFileSpan(FileSpan Function() builder) : _builder = builder; | ||
|
||
@override | ||
int compareTo(SourceSpan other) => span.compareTo(other); | ||
|
||
@override | ||
String get context => span.context; | ||
|
||
@override | ||
FileLocation get end => span.end; | ||
|
||
@override | ||
FileSpan expand(FileSpan other) => span.expand(other); | ||
|
||
@override | ||
SourceFile get file => span.file; | ||
|
||
@override | ||
String highlight({color}) => span.highlight(color: color); | ||
|
||
@override | ||
int get length => span.length; | ||
|
||
@override | ||
String message(String message, {color}) => | ||
span.message(message, color: color); | ||
|
||
@override | ||
Uri? get sourceUrl => span.sourceUrl; | ||
|
||
@override | ||
FileLocation get start => span.start; | ||
|
||
@override | ||
String get text => span.text; | ||
|
||
@override | ||
SourceSpan union(SourceSpan other) => span.union(other); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 6.0.3 | ||
|
||
* No user-visible changes. | ||
|
||
## 6.0.2 | ||
|
||
* No user-visible changes. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters