Skip to content

Commit 4952b35

Browse files
committed
Speed up checking whether entry is coming from a dependency
Doing filtering brefore fuzzy matching didn't improve performance, because retrieving full paths of entries is slow. Since the file paths are escaped in URIs, they're currently being unescaped with Windows handling in order to retrieve the raw path. This is extra work, because we know the raw path at the time we're building the URI, we just didn't store that information. Storing the raw path in the URI and retrieving it speeds up workspace symbol search ~4x in my application.
1 parent 5215014 commit 4952b35

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/ruby_indexer/lib/ruby_indexer/uri.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def from_path(path:, fragment: nil, scheme: "file", load_path_entry: nil)
3131
end
3232

3333
uri = build(scheme: scheme, path: escaped_path, fragment: fragment)
34+
uri.raw_path = path
3435

3536
if load_path_entry
3637
uri.require_path = path.delete_prefix("#{load_path_entry}/").delete_suffix(".rb")
@@ -40,6 +41,8 @@ def from_path(path:, fragment: nil, scheme: "file", load_path_entry: nil)
4041
end
4142
end
4243

44+
#: String
45+
attr_accessor :raw_path
4346
#: String?
4447
attr_accessor :require_path
4548

lib/ruby_lsp/requests/workspace_symbol.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def perform
4848

4949
def fuzzy_search
5050
@index.fuzzy_search(@query) do |entry|
51-
file_path = entry.uri.full_path
51+
file_path = entry.uri.raw_path
5252

5353
# We only show symbols declared in the workspace
5454
in_dependencies = file_path && !not_in_dependencies?(file_path)

0 commit comments

Comments
 (0)