Skip to content

Commit 3956362

Browse files
authored
perf: zero-copy UrlBuf to Url conversion (#3117)
1 parent dd7afaa commit 3956362

File tree

29 files changed

+433
-290
lines changed

29 files changed

+433
-290
lines changed

Cargo.lock

Lines changed: 37 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ ansi-to-tui = "7.0.0"
2424
anyhow = "1.0.99"
2525
base64 = "0.22.1"
2626
bitflags = { version = "2.9.3", features = [ "serde" ] }
27-
clap = { version = "4.5.45", features = [ "derive" ] }
27+
clap = { version = "4.5.46", features = [ "derive" ] }
2828
core-foundation-sys = "0.8.7"
2929
crossterm = { version = "0.29.0", features = [ "event-stream" ] }
3030
dirs = "6.0.0"
31-
foldhash = "0.1.5"
31+
foldhash = "0.2.0"
3232
futures = "0.3.31"
3333
globset = "0.4.16"
3434
hashbrown = { version = "0.15.5", features = [ "serde" ] }
@@ -41,7 +41,7 @@ ordered-float = { version = "5.0.0", features = [ "serde" ] }
4141
parking_lot = "0.12.4"
4242
paste = "1.0.15"
4343
ratatui = { version = "0.29.0", features = [ "unstable-rendered-line-info" ] }
44-
regex = "1.11.1"
44+
regex = "1.11.2"
4545
scopeguard = "1.2.0"
4646
serde = { version = "1.0.219", features = [ "derive" ] }
4747
serde_json = "1.0.143"

README.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div align="center">
2-
<sup>Special thanks to:</sup>
3-
<br><br>
4-
<a href="https://www.warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=yazi" target="_blank">
5-
<img alt="Warp sponsorship" width="300" src="https://github.com/user-attachments/assets/c7f141e7-9751-407d-bb0e-d6f2c487b34f">
6-
<br>
7-
<b>Warp, the intelligent terminal</b>
8-
<br>
9-
<sup>Yazi's AI-powered terminal of choice!<br>Available for macOS, Linux and Windows</sup>
10-
</a>
2+
<a href="https://go.warp.dev/yazi" target="_blank">
3+
<sup>Special thanks to:</sup>
4+
<br>
5+
<img alt="Warp sponsorship" width="400" src="https://github.com/warpdotdev/brand-assets/blob/main/Github/Sponsor/Warp-Github-LG-02.png">
6+
<br>
7+
<h>Warp, built for coding with multiple AI agents</b>
8+
<br>
9+
<sup>Available for macOS, Linux and Windows</sup>
10+
</a>
1111
</div>
1212

1313
<br>
@@ -52,25 +52,25 @@ Yazi is currently in heavy development, expect breaking changes.
5252

5353
## Image Preview
5454

55-
| Platform | Protocol | Support |
56-
| ---------------------------------------------------------------------------- | -------------------------------------- | ----------------------------------------------------- |
57-
| [kitty](https://github.com/kovidgoyal/kitty) (>= 0.28.0) | [Kitty unicode placeholders][kgp] | ✅ Built-in |
58-
| [iTerm2](https://iterm2.com) | [Inline images protocol][iip] | ✅ Built-in |
59-
| [WezTerm](https://github.com/wez/wezterm) | [Inline images protocol][iip] | ✅ Built-in |
60-
| [Konsole](https://invent.kde.org/utilities/konsole) | [Kitty old protocol][kgp-old] | ✅ Built-in |
61-
| [foot](https://codeberg.org/dnkl/foot) | [Sixel graphics format][sixel] | ✅ Built-in |
62-
| [Ghostty](https://github.com/ghostty-org/ghostty) | [Kitty unicode placeholders][kgp] | ✅ Built-in |
63-
| [Windows Terminal](https://github.com/microsoft/terminal) (>= v1.22.10352.0) | [Sixel graphics format][sixel] | ✅ Built-in |
64-
| [st with Sixel patch](https://github.com/bakkeby/st-flexipatch) | [Sixel graphics format][sixel] | ✅ Built-in |
65-
| [Warp](https://www.warp.dev) (macOS/Linux only) | [Inline images protocol][iip] | ✅ Built-in |
66-
| [Tabby](https://github.com/Eugeny/tabby) | [Inline images protocol][iip] | ✅ Built-in |
67-
| [VSCode](https://github.com/microsoft/vscode) | [Inline images protocol][iip] | ✅ Built-in |
68-
| [Rio](https://github.com/raphamorim/rio) | [Inline images protocol][iip] | ✅ Built-in |
69-
| [Black Box](https://gitlab.gnome.org/raggesilver/blackbox) | [Sixel graphics format][sixel] | ✅ Built-in |
70-
| [Hyper](https://github.com/vercel/hyper) | [Inline images protocol][iip] | ✅ Built-in |
71-
| [Bobcat](https://github.com/ismail-yilmaz/Bobcat) | [Inline images protocol][iip] | ✅ Built-in |
72-
| X11 / Wayland | Window system protocol | ☑️ [Überzug++][ueberzug] required |
73-
| Fallback | [ASCII art (Unicode block)][ascii-art] | ☑️ [Chafa][chafa] required |
55+
| Platform | Protocol | Support |
56+
| ---------------------------------------------------------------------------- | -------------------------------------- | --------------------------------- |
57+
| [kitty](https://github.com/kovidgoyal/kitty) (>= 0.28.0) | [Kitty unicode placeholders][kgp] | ✅ Built-in |
58+
| [iTerm2](https://iterm2.com) | [Inline images protocol][iip] | ✅ Built-in |
59+
| [WezTerm](https://github.com/wez/wezterm) | [Inline images protocol][iip] | ✅ Built-in |
60+
| [Konsole](https://invent.kde.org/utilities/konsole) | [Kitty old protocol][kgp-old] | ✅ Built-in |
61+
| [foot](https://codeberg.org/dnkl/foot) | [Sixel graphics format][sixel] | ✅ Built-in |
62+
| [Ghostty](https://github.com/ghostty-org/ghostty) | [Kitty unicode placeholders][kgp] | ✅ Built-in |
63+
| [Windows Terminal](https://github.com/microsoft/terminal) (>= v1.22.10352.0) | [Sixel graphics format][sixel] | ✅ Built-in |
64+
| [st with Sixel patch](https://github.com/bakkeby/st-flexipatch) | [Sixel graphics format][sixel] | ✅ Built-in |
65+
| [Warp](https://www.warp.dev) (macOS/Linux only) | [Inline images protocol][iip] | ✅ Built-in |
66+
| [Tabby](https://github.com/Eugeny/tabby) | [Inline images protocol][iip] | ✅ Built-in |
67+
| [VSCode](https://github.com/microsoft/vscode) | [Inline images protocol][iip] | ✅ Built-in |
68+
| [Rio](https://github.com/raphamorim/rio) | [Inline images protocol][iip] | ✅ Built-in |
69+
| [Black Box](https://gitlab.gnome.org/raggesilver/blackbox) | [Sixel graphics format][sixel] | ✅ Built-in |
70+
| [Hyper](https://github.com/vercel/hyper) | [Inline images protocol][iip] | ✅ Built-in |
71+
| [Bobcat](https://github.com/ismail-yilmaz/Bobcat) | [Inline images protocol][iip] | ✅ Built-in |
72+
| X11 / Wayland | Window system protocol | ☑️ [Überzug++][ueberzug] required |
73+
| Fallback | [ASCII art (Unicode block)][ascii-art] | ☑️ [Chafa][chafa] required |
7474

7575
See https://yazi-rs.github.io/docs/image-preview for details.
7676

yazi-actor/src/cmp/trigger.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ impl Trigger {
7979
const SEP: char = std::path::MAIN_SEPARATOR;
8080

8181
Some(match path.as_os_str().rsplit_once(SEP) {
82-
Some((p, c)) if p.is_empty() => (UrlBuf { loc: MAIN_SEPARATOR_STR.into(), scheme }, c.into()),
83-
Some((p, c)) => (expand_url(UrlBuf { loc: p.into(), scheme }), c.into()),
82+
Some((p, c)) if p.is_empty() => {
83+
(UrlBuf { loc: MAIN_SEPARATOR_STR.into(), scheme: scheme.into() }, c.into())
84+
}
85+
Some((p, c)) => (expand_url(UrlBuf { loc: p.into(), scheme: scheme.into() }), c.into()),
8486
None => (CWD.load().as_ref().clone(), path.into()),
8587
})
8688
}

yazi-actor/src/mgr/cd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Actor for Cd {
5353

5454
// Parent
5555
if let Some(parent) = opt.target.parent() {
56-
tab.parent = Some(tab.history.remove_or(&parent));
56+
tab.parent = Some(tab.history.remove_or(parent));
5757
}
5858

5959
err!(Pubsub::pub_after_cd(tab.id, tab.cwd()));

yazi-actor/src/mgr/create.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Create {
5353
FilesOp::Deleting(parent.into(), [urn.into()].into()).emit();
5454
provider::create(&new).await?;
5555
} else if let Some(parent) = new.parent() {
56-
provider::create_dir_all(&parent).await.ok();
56+
provider::create_dir_all(parent).await.ok();
5757
ok_or_not_found(provider::remove_file(&new).await)?;
5858
provider::create(&new).await?;
5959
} else {

yazi-actor/src/mgr/reveal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl Actor for Reveal {
1717
let Some((parent, child)) = opt.target.pair() else { succ!() };
1818

1919
// Cd to the parent directory
20-
act!(mgr:cd, cx, (parent.clone(), opt.source))?;
20+
act!(mgr:cd, cx, (parent, opt.source))?;
2121

2222
// Try to hover on the child file
2323
let tab = cx.tab_mut();

yazi-binding/src/url.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ impl<'a> From<&'a Url> for yazi_shared::url::Url<'a> {
3838
}
3939

4040
impl<'a> From<&'a Url> for UrlCow<'a> {
41-
fn from(value: &'a Url) -> Self { UrlCow::Borrowed(value.as_url()) }
41+
fn from(value: &'a Url) -> Self {
42+
UrlCow::Borrowed { loc: value.loc.as_loc(), scheme: value.scheme.as_ref().into() }
43+
}
4244
}
4345

4446
impl From<Url> for yazi_shared::url::UrlBufCov {

yazi-config/src/pattern.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::str::FromStr;
33
use anyhow::Result;
44
use globset::GlobBuilder;
55
use serde::Deserialize;
6-
use yazi_shared::url::{Scheme, UrlBuf};
6+
use yazi_shared::{scheme::{SchemeCow, SchemeRef}, url::UrlBuf};
77

88
#[derive(Debug, Deserialize)]
99
#[serde(try_from = "String")]
@@ -108,14 +108,16 @@ impl PatternScheme {
108108
};
109109

110110
if protocol != "*" {
111-
me.0 = Some(Scheme::parse_kind(protocol.as_bytes())?);
111+
me.0 = Some(SchemeCow::parse_kind(protocol.as_bytes())?);
112112
}
113113

114114
Ok((me, protocol.len() + 3))
115115
}
116116

117117
#[inline]
118-
fn matches(&self, scheme: &Scheme) -> bool { self.0.is_none_or(|s| s == scheme.kind()) }
118+
fn matches<'a>(&self, scheme: impl Into<SchemeRef<'a>>) -> bool {
119+
self.0.is_none_or(|s| s == scheme.into().kind())
120+
}
119121
}
120122

121123
// --- Tests

0 commit comments

Comments
 (0)