Skip to content

Commit

Permalink
Return early from bootstraping symbols if paths are empty (#2078)
Browse files Browse the repository at this point in the history
### Motivation

Another tiny improvement that I identified during studying memory dumps. When passing a constant list to Tapioca, we end up invoking `symbols_from_paths` with an empty array.

Currently, it will still create an empty tempfile and run Sorbet on it, which is unnecessary.

### Implementation

We can return an empty set directly if no paths are given.
  • Loading branch information
vinistock authored Nov 20, 2024
2 parents 768aab0 + e764ae1 commit d98e8dc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/tapioca/static/symbol_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def gem_symbols(gem)

sig { params(paths: T::Array[Pathname]).returns(T::Set[String]) }
def symbols_from_paths(paths)
return Set.new if paths.empty?

output = Tempfile.create("sorbet") do |file|
file.write(Array(paths).join("\n"))
file.flush
Expand Down

0 comments on commit d98e8dc

Please sign in to comment.