Yochem van Rosmalen
dc5d313d66
fix(vim.fs): joinpath() should ignore empty items #38077
...
Problem:
vim.fs.joinpath treats empty string as a path segment
(it adds a path separator for each empty item):
print(vim.fs.joinpath('', 'after/lsp', '')) -- '/after/lsp/'
print(vim.fs.joinpath('', '')) -- '/'
Especially problematic if the empty segment is the first segment, as
that converts the path to an absolute path.
Solution:
Ignore empty (length of 0) path segments.
Benchmark:
local function test(func)
local t = vim.uv.hrtime()
for _ = 1, 100000, 1 do
func('', 'this/is', 'a/very/long/path', '', 'it', 'really', 'is')
end
print(math.floor((vim.uv.hrtime() - t) / 1e6), 'ms')
end
- with Iter():filter() --> 370 ms
- building new segments table --> 208 ms
- with vim.tbl_filter --> 232 ms
- Instead of gsub split on `/` in all parts --> 1870 ms
2026-02-27 17:45:07 -05:00
..
2026-02-20 18:35:55 -05:00
2026-02-23 10:10:20 -05:00
2026-02-26 21:30:44 +08:00
2026-01-09 01:36:04 +00:00
2026-02-12 13:46:45 +01:00
2026-02-11 08:02:23 +08:00
2025-11-28 10:10:31 +08:00
2026-02-03 22:25:18 +08:00
2026-02-12 13:46:45 +01:00
2026-02-12 13:46:45 +01:00
2026-02-18 11:58:34 -05:00
2024-05-15 23:19:26 +02:00
2026-02-18 11:58:34 -05:00
2026-01-04 14:15:23 +08:00
2026-02-12 13:46:45 +01:00
2026-02-14 06:07:01 -05:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2026-02-25 20:55:05 -06:00
2025-12-06 20:33:02 -05:00
2026-02-18 18:06:35 +01:00
2025-11-10 11:13:56 +08:00
2025-12-06 20:33:02 -05:00
2025-05-03 10:08:53 -07:00
2025-05-03 10:08:53 -07:00
2023-06-25 17:14:28 +02:00
2026-01-27 07:20:41 +08:00
2025-09-07 20:45:22 -07:00
2026-02-14 05:34:30 -05:00
2025-04-27 10:32:25 -07:00
2026-02-14 05:30:18 -05:00
2025-12-06 20:33:02 -05:00
2025-11-10 11:13:56 +08:00
2026-01-29 07:19:20 +08:00
2026-01-27 17:14:57 -05:00
2025-11-10 11:13:56 +08:00
2025-12-16 13:46:04 -05:00
2026-01-12 03:50:57 +00:00
2026-01-09 16:38:26 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2026-01-26 07:05:42 +08:00
2026-01-26 07:05:42 +08:00
2026-02-26 12:05:30 -05:00
2025-08-02 15:58:11 -07:00
2025-12-15 13:55:15 -05:00
2026-02-12 13:46:45 +01:00
2026-02-27 17:45:07 -05:00
2025-12-15 13:55:15 -05:00
2026-01-23 09:30:37 +01:00
2026-02-12 13:46:45 +01:00
2025-12-15 13:55:15 -05:00
2026-02-14 10:55:48 -05:00
2025-11-10 11:13:56 +08:00
2026-02-10 06:44:30 +08:00
2025-09-28 20:57:59 -07:00
2025-10-04 21:09:13 -07:00
2026-02-09 12:13:24 -05:00
2026-02-26 21:30:44 +08:00
2025-12-15 13:55:15 -05:00
2026-02-26 21:30:44 +08:00
2026-01-29 16:24:33 +02:00
2026-01-29 08:22:51 +08:00
2025-11-10 11:13:56 +08:00
2025-12-15 13:55:15 -05:00
2025-11-10 11:13:56 +08:00
2023-01-01 15:05:13 +01:00
2025-08-11 00:04:30 +00:00
2025-05-20 00:21:30 +00:00
2025-12-06 20:33:02 -05:00
2025-12-15 13:55:15 -05:00
2026-02-04 13:53:08 -05:00
2026-02-09 12:13:24 -05:00
2025-12-20 22:07:27 -05:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2026-02-01 08:30:59 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2026-01-26 06:44:11 +08:00
2026-02-26 21:30:44 +08:00
2026-02-05 21:39:08 +08:00
2026-02-20 18:35:55 -05:00
2025-11-10 11:13:56 +08:00
2026-02-09 12:13:24 -05:00
2026-01-27 17:14:57 -05:00
2025-11-10 11:13:56 +08:00
2026-02-12 08:07:13 -05:00
2025-12-15 02:07:51 -05:00
2026-01-07 08:11:42 +08:00
2025-11-12 09:00:27 -08:00
2025-12-21 07:12:38 +08:00
2025-11-10 11:13:56 +08:00
2026-02-13 16:39:18 +08:00
2025-12-06 20:33:02 -05:00
2025-11-10 11:13:56 +08:00
2026-01-25 08:17:33 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-27 07:49:44 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-12-06 20:33:02 -05:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2026-02-13 16:39:18 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-12-15 13:55:15 -05:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-29 00:22:24 +00:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2026-02-16 21:17:02 +08:00
2025-11-10 11:13:56 +08:00
2026-02-13 16:39:18 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2025-11-10 11:13:56 +08:00
2026-02-09 12:13:24 -05:00
2025-12-28 08:18:48 +08:00
2026-02-20 18:35:55 -05:00
2025-11-10 11:13:56 +08:00
2026-02-25 03:38:08 -05:00
2026-02-14 07:59:51 +08:00