perf: remove intermediate variables in natural sorting algorithm to avoid unnecessary allocation (#2764)

This commit is contained in:
三咲雅 · Misaki Masa 2025-05-16 16:26:22 +08:00 committed by GitHub
parent 464acfe47b
commit e257581fe7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 101 additions and 66 deletions

24
Cargo.lock generated
View file

@ -780,9 +780,9 @@ dependencies = [
[[package]]
name = "errno"
version = "0.3.11"
version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18"
dependencies = [
"libc",
"windows-sys 0.59.0",
@ -1085,7 +1085,7 @@ dependencies = [
"js-sys",
"log",
"wasm-bindgen",
"windows-core 0.61.0",
"windows-core 0.61.1",
]
[[package]]
@ -3006,9 +3006,9 @@ dependencies = [
[[package]]
name = "weezl"
version = "0.1.9"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78c888f2a25014723b17ac60a626d626549f773e0d702b1320956f8d769ae1f8"
checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
[[package]]
name = "which"
@ -3087,14 +3087,14 @@ dependencies = [
[[package]]
name = "windows-core"
version = "0.61.0"
version = "0.61.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980"
checksum = "46ec44dc15085cea82cf9c78f85a9114c463a369786585ad2882d1ff0b0acf40"
dependencies = [
"windows-implement 0.60.0",
"windows-interface 0.59.1",
"windows-link",
"windows-result 0.3.2",
"windows-result 0.3.3",
"windows-strings",
]
@ -3159,18 +3159,18 @@ dependencies = [
[[package]]
name = "windows-result"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252"
checksum = "4b895b5356fc36103d0f64dd1e94dfa7ac5633f1c9dd6e80fe9ec4adef69e09d"
dependencies = [
"windows-link",
]
[[package]]
name = "windows-strings"
version = "0.4.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97"
checksum = "2a7ab927b2637c19b3dbe0965e75d8f2d30bdd697a1516191cad2ec4df8fb28a"
dependencies = [
"windows-link",
]

View file

@ -1,5 +1,11 @@
local dark = require("icons-default")
local light = require("icons-light")
local dark = {
icons_by_filename = require("default.icons_by_filename"),
icons_by_file_extension = require("default.icons_by_file_extension"),
}
local light = {
icons_by_filename = require("light.icons_by_filename"),
icons_by_file_extension = require("light.icons_by_file_extension"),
}
function rearrange(by)
local map = {}

View file

@ -32,15 +32,18 @@
}
},
"node_modules/@actions/github": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@actions/github/-/github-6.0.0.tgz",
"integrity": "sha512-alScpSVnYmjNEXboZjarjukQEzgCRmjMv6Xj47fsdnqGS73bjJNDpiiXmp8jr0UZLdUB6d9jW63IcmddUP+l0g==",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/@actions/github/-/github-6.0.1.tgz",
"integrity": "sha512-xbZVcaqD4XnQAe35qSQqskb3SqIAfRyLBrHMd/8TuL7hJSz2QtbDwnNM8zWx4zO5l2fnGtseNE3MbEvD7BxVMw==",
"license": "MIT",
"dependencies": {
"@actions/http-client": "^2.2.0",
"@octokit/core": "^5.0.1",
"@octokit/plugin-paginate-rest": "^9.0.0",
"@octokit/plugin-rest-endpoint-methods": "^10.0.0"
"@octokit/plugin-paginate-rest": "^9.2.2",
"@octokit/plugin-rest-endpoint-methods": "^10.4.0",
"@octokit/request": "^8.4.1",
"@octokit/request-error": "^5.1.1",
"undici": "^5.28.5"
}
},
"node_modules/@actions/http-client": {
@ -78,15 +81,15 @@
}
},
"node_modules/@octokit/core": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.0.tgz",
"integrity": "sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==",
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.1.tgz",
"integrity": "sha512-dKYCMuPO1bmrpuogcjQ8z7ICCH3FP6WmxpwC03yjzGfZhj9fTJg6+bS1+UAplekbN2C+M61UNllGOOoAfGCrdQ==",
"license": "MIT",
"dependencies": {
"@octokit/auth-token": "^4.0.0",
"@octokit/graphql": "^7.1.0",
"@octokit/request": "^8.3.1",
"@octokit/request-error": "^5.1.0",
"@octokit/request": "^8.4.1",
"@octokit/request-error": "^5.1.1",
"@octokit/types": "^13.0.0",
"before-after-hook": "^2.2.0",
"universal-user-agent": "^6.0.0"
@ -109,12 +112,12 @@
}
},
"node_modules/@octokit/graphql": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.1.0.tgz",
"integrity": "sha512-r+oZUH7aMFui1ypZnAvZmn0KSqAUgE1/tUXIWaqUCa1758ts/Jio84GZuzsvUkme98kv0WFY8//n0J1Z+vsIsQ==",
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.1.1.tgz",
"integrity": "sha512-3mkDltSfcDUoa176nlGoA32RGjeWjl3K7F/BwHwRMJUW/IteSa4bnSV8p2ThNkcIcZU2umkZWxwETSSCJf2Q7g==",
"license": "MIT",
"dependencies": {
"@octokit/request": "^8.3.0",
"@octokit/request": "^8.4.1",
"@octokit/types": "^13.0.0",
"universal-user-agent": "^6.0.0"
},
@ -123,9 +126,9 @@
}
},
"node_modules/@octokit/openapi-types": {
"version": "23.0.1",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-23.0.1.tgz",
"integrity": "sha512-izFjMJ1sir0jn0ldEKhZ7xegCTj/ObmEDlEfpFrx4k/JyZSMRHbO3/rBwgE7f3m2DHt+RrNGIVw4wSmwnm3t/g==",
"version": "24.2.0",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-24.2.0.tgz",
"integrity": "sha512-9sIH3nSUttelJSXUrmGzl7QUBFul0/mB8HRYl3fOlgHbIWG+WnYDXU3v/2zMtAvuzZ/ed00Ei6on975FhBfzrg==",
"license": "MIT"
},
"node_modules/@octokit/plugin-paginate-rest": {
@ -218,12 +221,12 @@
}
},
"node_modules/@octokit/types": {
"version": "13.8.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.8.0.tgz",
"integrity": "sha512-x7DjTIbEpEWXK99DMd01QfWy0hd5h4EN+Q7shkdKds3otGQP+oWE/y0A76i1OvH9fygo4ddvNf7ZvF0t78P98A==",
"version": "13.10.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.10.0.tgz",
"integrity": "sha512-ifLaO34EbbPj0Xgro4G5lP5asESjwHracYJvVaPIyXMuiuXLlhic3S47cBdTb+jfODkTE5YtGCLt3Ay3+J97sA==",
"license": "MIT",
"dependencies": {
"@octokit/openapi-types": "^23.0.1"
"@octokit/openapi-types": "^24.2.0"
}
},
"node_modules/before-after-hook": {
@ -257,9 +260,9 @@
}
},
"node_modules/undici": {
"version": "5.28.5",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz",
"integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==",
"license": "MIT",
"dependencies": {
"@fastify/busboy": "^2.0.0"

View file

@ -336,6 +336,7 @@ files = [
{ name = "build", text = "", fg = "#89e051" },
{ name = "build.gradle", text = "", fg = "#005f87" },
{ name = "build.zig.zon", text = "", fg = "#f69a1b" },
{ name = "bun.lock", text = "", fg = "#eadcd1" },
{ name = "bun.lockb", text = "", fg = "#eadcd1" },
{ name = "cantorrc", text = "", fg = "#1c99f3" },
{ name = "checkhealth", text = "󰓙", fg = "#75b4fb" },
@ -368,9 +369,9 @@ files = [
{ name = "FreeCAD.conf", text = "", fg = "#cb333b" },
{ name = "Gemfile", text = "", fg = "#701516" },
{ name = "gnumakefile", text = "", fg = "#6d8086" },
{ name = "go.mod", text = "", fg = "#519aba" },
{ name = "go.sum", text = "", fg = "#519aba" },
{ name = "go.work", text = "", fg = "#519aba" },
{ name = "go.mod", text = "", fg = "#00add8" },
{ name = "go.sum", text = "", fg = "#00add8" },
{ name = "go.work", text = "", fg = "#00add8" },
{ name = "gradle-wrapper.properties", text = "", fg = "#005f87" },
{ name = "gradle.properties", text = "", fg = "#005f87" },
{ name = "gradlew", text = "", fg = "#005f87" },
@ -386,6 +387,7 @@ files = [
{ name = "gulpfile.ts", text = "", fg = "#cc3e44" },
{ name = "hypridle.conf", text = "", fg = "#00aaae" },
{ name = "hyprland.conf", text = "", fg = "#00aaae" },
{ name = "hyprlandd.conf", text = "", fg = "#00aaae" },
{ name = "hyprlock.conf", text = "", fg = "#00aaae" },
{ name = "hyprpaper.conf", text = "", fg = "#00aaae" },
{ name = "i18n.config.js", text = "󰗊", fg = "#7986cb" },
@ -451,6 +453,8 @@ files = [
{ name = "webpack", text = "󰜫", fg = "#519aba" },
{ name = "weston.ini", text = "", fg = "#ffbb01" },
{ name = "workspace", text = "", fg = "#89e051" },
{ name = "wrangler.jsonc", text = "", fg = "#f48120" },
{ name = "wrangler.toml", text = "", fg = "#f48120" },
{ name = "xmobarrc", text = "", fg = "#fd4d5d" },
{ name = "xmobarrc.hs", text = "", fg = "#fd4d5d" },
{ name = "xmonad.hs", text = "", fg = "#fd4d5d" },
@ -463,8 +467,9 @@ exts = [
{ name = "7z", text = "", fg = "#eca517" },
{ name = "a", text = "", fg = "#dcddd6" },
{ name = "aac", text = "", fg = "#00afff" },
{ name = "adb", text = "", fg = "#22ffff" },
{ name = "ads", text = "", fg = "#ffffff" },
{ name = "ada", text = "", fg = "#599eff" },
{ name = "adb", text = "", fg = "#599eff" },
{ name = "ads", text = "", fg = "#a074c4" },
{ name = "ai", text = "", fg = "#cbcb41" },
{ name = "aif", text = "", fg = "#00afff" },
{ name = "aiff", text = "", fg = "#00afff" },
@ -531,7 +536,7 @@ exts = [
{ name = "cshtml", text = "󱦗", fg = "#512bd4" },
{ name = "cson", text = "", fg = "#cbcb41" },
{ name = "csproj", text = "󰪮", fg = "#512bd4" },
{ name = "css", text = "", fg = "#42a5f5" },
{ name = "css", text = "", fg = "#663399" },
{ name = "csv", text = "", fg = "#89e051" },
{ name = "cts", text = "", fg = "#519aba" },
{ name = "cu", text = "", fg = "#89e051" },
@ -549,6 +554,7 @@ exts = [
{ name = "dll", text = "", fg = "#4d2c0b" },
{ name = "doc", text = "󰈬", fg = "#185abd" },
{ name = "Dockerfile", text = "󰡨", fg = "#458ee6" },
{ name = "dockerignore", text = "󰡨", fg = "#458ee6" },
{ name = "docx", text = "󰈬", fg = "#185abd" },
{ name = "dot", text = "󱁉", fg = "#30638e" },
{ name = "download", text = "", fg = "#44cda8" },
@ -590,6 +596,7 @@ exts = [
{ name = "fctb", text = "", fg = "#cb333b" },
{ name = "fctl", text = "", fg = "#cb333b" },
{ name = "fdmdownload", text = "", fg = "#44cda8" },
{ name = "feature", text = "", fg = "#00a818" },
{ name = "fish", text = "", fg = "#4d5a5e" },
{ name = "flac", text = "", fg = "#0075aa" },
{ name = "flc", text = "", fg = "#ececec" },
@ -611,9 +618,9 @@ exts = [
{ name = "glb", text = "", fg = "#ffb13b" },
{ name = "gleam", text = "", fg = "#ffaff3" },
{ name = "gnumakefile", text = "", fg = "#6d8086" },
{ name = "go", text = "", fg = "#519aba" },
{ name = "go", text = "", fg = "#00add8" },
{ name = "godot", text = "", fg = "#6d8086" },
{ name = "gpr", text = "", fg = "#ff33ff" },
{ name = "gpr", text = "", fg = "#6d8086" },
{ name = "gql", text = "", fg = "#e535ab" },
{ name = "gradle", text = "", fg = "#005f87" },
{ name = "graphql", text = "", fg = "#e535ab" },
@ -840,6 +847,13 @@ exts = [
{ name = "ste", text = "󰻫", fg = "#839463" },
{ name = "step", text = "󰻫", fg = "#839463" },
{ name = "stl", text = "󰆧", fg = "#888888" },
{ name = "stories.js", text = "", fg = "#ff4785" },
{ name = "stories.jsx", text = "", fg = "#ff4785" },
{ name = "stories.mjs", text = "", fg = "#ff4785" },
{ name = "stories.svelte", text = "", fg = "#ff4785" },
{ name = "stories.ts", text = "", fg = "#ff4785" },
{ name = "stories.tsx", text = "", fg = "#ff4785" },
{ name = "stories.vue", text = "", fg = "#ff4785" },
{ name = "stp", text = "󰻫", fg = "#839463" },
{ name = "strings", text = "", fg = "#2596be" },
{ name = "styl", text = "", fg = "#8dc149" },
@ -849,6 +863,7 @@ exts = [
{ name = "sv", text = "󰍛", fg = "#019833" },
{ name = "svelte", text = "", fg = "#ff3e00" },
{ name = "svg", text = "󰜡", fg = "#ffb13b" },
{ name = "svgz", text = "󰜡", fg = "#ffb13b" },
{ name = "svh", text = "󰍛", fg = "#019833" },
{ name = "swift", text = "", fg = "#e37933" },
{ name = "t", text = "", fg = "#519aba" },
@ -864,6 +879,7 @@ exts = [
{ name = "tf", text = "", fg = "#5f43e9" },
{ name = "tfvars", text = "", fg = "#5f43e9" },
{ name = "tgz", text = "", fg = "#eca517" },
{ name = "tmpl", text = "", fg = "#dbbd30" },
{ name = "tmux", text = "", fg = "#14ba19" },
{ name = "toml", text = "", fg = "#9c4221" },
{ name = "torrent", text = "", fg = "#44cda8" },

View file

@ -336,6 +336,7 @@ files = [
{ name = "build", text = "", fg = "#447028" },
{ name = "build.gradle", text = "", fg = "#005f87" },
{ name = "build.zig.zon", text = "", fg = "#7b4d0e" },
{ name = "bun.lock", text = "", fg = "#4e4946" },
{ name = "bun.lockb", text = "", fg = "#4e4946" },
{ name = "cantorrc", text = "", fg = "#1573b6" },
{ name = "checkhealth", text = "󰓙", fg = "#3a5a7e" },
@ -368,9 +369,9 @@ files = [
{ name = "FreeCAD.conf", text = "", fg = "#98262c" },
{ name = "Gemfile", text = "", fg = "#701516" },
{ name = "gnumakefile", text = "", fg = "#526064" },
{ name = "go.mod", text = "", fg = "#36677c" },
{ name = "go.sum", text = "", fg = "#36677c" },
{ name = "go.work", text = "", fg = "#36677c" },
{ name = "go.mod", text = "", fg = "#0082a2" },
{ name = "go.sum", text = "", fg = "#0082a2" },
{ name = "go.work", text = "", fg = "#0082a2" },
{ name = "gradle-wrapper.properties", text = "", fg = "#005f87" },
{ name = "gradle.properties", text = "", fg = "#005f87" },
{ name = "gradlew", text = "", fg = "#005f87" },
@ -386,6 +387,7 @@ files = [
{ name = "gulpfile.ts", text = "", fg = "#992e33" },
{ name = "hypridle.conf", text = "", fg = "#008082" },
{ name = "hyprland.conf", text = "", fg = "#008082" },
{ name = "hyprlandd.conf", text = "", fg = "#008082" },
{ name = "hyprlock.conf", text = "", fg = "#008082" },
{ name = "hyprpaper.conf", text = "", fg = "#008082" },
{ name = "i18n.config.js", text = "󰗊", fg = "#515987" },
@ -451,6 +453,8 @@ files = [
{ name = "webpack", text = "󰜫", fg = "#36677c" },
{ name = "weston.ini", text = "", fg = "#805e00" },
{ name = "workspace", text = "", fg = "#447028" },
{ name = "wrangler.jsonc", text = "", fg = "#a35615" },
{ name = "wrangler.toml", text = "", fg = "#a35615" },
{ name = "xmobarrc", text = "", fg = "#a9333e" },
{ name = "xmobarrc.hs", text = "", fg = "#a9333e" },
{ name = "xmonad.hs", text = "", fg = "#a9333e" },
@ -463,8 +467,9 @@ exts = [
{ name = "7z", text = "", fg = "#76520c" },
{ name = "a", text = "", fg = "#494a47" },
{ name = "aac", text = "", fg = "#0075aa" },
{ name = "adb", text = "", fg = "#118080" },
{ name = "ads", text = "", fg = "#333333" },
{ name = "ada", text = "", fg = "#3b69aa" },
{ name = "adb", text = "", fg = "#3b69aa" },
{ name = "ads", text = "", fg = "#6b4d83" },
{ name = "ai", text = "", fg = "#666620" },
{ name = "aif", text = "", fg = "#0075aa" },
{ name = "aiff", text = "", fg = "#0075aa" },
@ -531,7 +536,7 @@ exts = [
{ name = "cshtml", text = "󱦗", fg = "#512bd4" },
{ name = "cson", text = "", fg = "#666620" },
{ name = "csproj", text = "󰪮", fg = "#512bd4" },
{ name = "css", text = "", fg = "#2c6ea3" },
{ name = "css", text = "", fg = "#663399" },
{ name = "csv", text = "", fg = "#447028" },
{ name = "cts", text = "", fg = "#36677c" },
{ name = "cu", text = "", fg = "#447028" },
@ -549,6 +554,7 @@ exts = [
{ name = "dll", text = "", fg = "#4d2c0b" },
{ name = "doc", text = "󰈬", fg = "#185abd" },
{ name = "Dockerfile", text = "󰡨", fg = "#2e5f99" },
{ name = "dockerignore", text = "󰡨", fg = "#2e5f99" },
{ name = "docx", text = "󰈬", fg = "#185abd" },
{ name = "dot", text = "󱁉", fg = "#244a6a" },
{ name = "download", text = "", fg = "#226654" },
@ -590,6 +596,7 @@ exts = [
{ name = "fctb", text = "", fg = "#98262c" },
{ name = "fctl", text = "", fg = "#98262c" },
{ name = "fdmdownload", text = "", fg = "#226654" },
{ name = "feature", text = "", fg = "#007e12" },
{ name = "fish", text = "", fg = "#3a4446" },
{ name = "flac", text = "", fg = "#005880" },
{ name = "flc", text = "", fg = "#2f2f2f" },
@ -611,9 +618,9 @@ exts = [
{ name = "glb", text = "", fg = "#80581e" },
{ name = "gleam", text = "", fg = "#553a51" },
{ name = "gnumakefile", text = "", fg = "#526064" },
{ name = "go", text = "", fg = "#36677c" },
{ name = "go", text = "", fg = "#0082a2" },
{ name = "godot", text = "", fg = "#526064" },
{ name = "gpr", text = "", fg = "#aa22aa" },
{ name = "gpr", text = "", fg = "#526064" },
{ name = "gql", text = "", fg = "#ac2880" },
{ name = "gradle", text = "", fg = "#005f87" },
{ name = "graphql", text = "", fg = "#ac2880" },
@ -840,6 +847,13 @@ exts = [
{ name = "ste", text = "󰻫", fg = "#576342" },
{ name = "step", text = "󰻫", fg = "#576342" },
{ name = "stl", text = "󰆧", fg = "#5b5b5b" },
{ name = "stories.js", text = "", fg = "#aa2f59" },
{ name = "stories.jsx", text = "", fg = "#aa2f59" },
{ name = "stories.mjs", text = "", fg = "#aa2f59" },
{ name = "stories.svelte", text = "", fg = "#aa2f59" },
{ name = "stories.ts", text = "", fg = "#aa2f59" },
{ name = "stories.tsx", text = "", fg = "#aa2f59" },
{ name = "stories.vue", text = "", fg = "#aa2f59" },
{ name = "stp", text = "󰻫", fg = "#576342" },
{ name = "strings", text = "", fg = "#1c708e" },
{ name = "styl", text = "", fg = "#466024" },
@ -849,6 +863,7 @@ exts = [
{ name = "sv", text = "󰍛", fg = "#017226" },
{ name = "svelte", text = "", fg = "#bf2e00" },
{ name = "svg", text = "󰜡", fg = "#80581e" },
{ name = "svgz", text = "󰜡", fg = "#80581e" },
{ name = "svh", text = "󰍛", fg = "#017226" },
{ name = "swift", text = "", fg = "#975122" },
{ name = "t", text = "", fg = "#36677c" },
@ -864,6 +879,7 @@ exts = [
{ name = "tf", text = "", fg = "#4732af" },
{ name = "tfvars", text = "", fg = "#4732af" },
{ name = "tgz", text = "", fg = "#76520c" },
{ name = "tmpl", text = "", fg = "#6e5e18" },
{ name = "tmux", text = "", fg = "#0f8c13" },
{ name = "toml", text = "", fg = "#753219" },
{ name = "torrent", text = "", fg = "#226654" },

View file

@ -1,4 +1,4 @@
use std::{cmp::Ordering, collections::HashMap, mem};
use std::{cmp::Ordering, collections::HashMap};
use yazi_shared::{LcgRng, natsort, translit::Transliterator, url::UrnBuf};
@ -14,7 +14,7 @@ pub struct FilesSorter {
}
impl FilesSorter {
pub(super) fn sort(&self, items: &mut Vec<File>, sizes: &HashMap<UrnBuf, u64>) {
pub(super) fn sort(&self, items: &mut [File], sizes: &HashMap<UrnBuf, u64>) {
if items.is_empty() {
return;
}
@ -64,11 +64,8 @@ impl FilesSorter {
}
}
fn sort_naturally(&self, items: &mut Vec<File>) {
let mut indices: Vec<usize> = (0..items.len()).collect();
indices.sort_unstable_by(|&a, &b| {
let (a, b) = (&items[a], &items[b]);
fn sort_naturally(&self, items: &mut [File]) {
items.sort_unstable_by(|a, b| {
let promote = self.promote(a, b);
if promote != Ordering::Equal {
return promote;
@ -86,8 +83,6 @@ impl FilesSorter {
if self.reverse { ordering.reverse() } else { ordering }
});
*items = indices.into_iter().map(|i| mem::take(&mut items[i])).collect();
}
#[inline(always)]

View file

@ -100,7 +100,7 @@ function Entity:ellipsis(max)
local adv, f = 0, self._file
for _, child in ipairs(self._children) do
adv = adv + child.width
if adv > max then
if adv >= max then
return not f.cha.is_dir and f.url.ext and "…." .. f.url.ext or ""
elseif child.id == 4 then
break

View file

@ -32,8 +32,7 @@ impl Utils {
let (mut adv, mut last) = (0, 0);
let idx = it
.take_while(|&(_, c)| {
last = adv;
adv += c.width().unwrap_or(0);
(last, adv) = (adv, adv + c.width().unwrap_or(0));
adv <= max
})
.map(|(i, _)| i)