editor: Shrink DisplayMapSnapshot from 824 to 256 bytes (#39568)

We have unnecessary clones for the fields here as most of the snapshots
contain the others hierarchically.

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-06 08:08:49 +00:00
committed by GitHub
parent 9c7369f54d
commit 2bfcd60b88
48 changed files with 594 additions and 543 deletions
+5 -5
View File
@@ -49,8 +49,8 @@ impl RangeInEditor {
) -> bool {
match (self, trigger_point) {
(Self::Text(range), TriggerPoint::Text(point)) => {
let point_after_start = range.start.cmp(point, &snapshot.buffer_snapshot).is_le();
point_after_start && range.end.cmp(point, &snapshot.buffer_snapshot).is_ge()
let point_after_start = range.start.cmp(point, &snapshot.buffer_snapshot()).is_le();
point_after_start && range.end.cmp(point, &snapshot.buffer_snapshot()).is_ge()
}
(Self::Inlay(highlight), TriggerPoint::InlayHint(point, _, _)) => {
highlight.inlay == point.inlay
@@ -131,7 +131,7 @@ impl Editor {
Some(point) => {
let trigger_point = TriggerPoint::Text(
snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_before(point.to_offset(&snapshot.display_snapshot, Bias::Left)),
);
@@ -326,7 +326,7 @@ pub fn update_inlay_link_and_hover_points(
match cached_hint.resolve_state {
ResolveState::CanResolve(_, _) => {
if let Some(buffer_id) = snapshot
.buffer_snapshot
.buffer_snapshot()
.buffer_id_for_anchor(previous_valid_anchor)
{
inlay_hint_cache.spawn_hint_resolve(
@@ -534,7 +534,7 @@ pub fn show_link_definition(
let project = editor.project.clone();
let provider = editor.semantics_provider.clone();
let snapshot = snapshot.buffer_snapshot.clone();
let snapshot = snapshot.buffer_snapshot().clone();
hovered_link_state.task = Some(cx.spawn_in(window, async move |this, cx| {
async move {
let result = match &trigger_point {