Having the fact that File.extname returns an empty string on the edge cases (no extension, '.', not-valid-paths, etc), we can remove a superflous if statement and replace the inner else with a single guard.
This improve the performance up to 10% on cached and non_cached values
Also, we can reduce the allocated memory:
Having the fact that
File.extname
returns an empty string on the edge cases (no extension, '.', not-valid-paths, etc), we can remove a superflousif
statement and replace the innerelse
with a single guard.This improve the performance up to 10% on cached and non_cached values Also, we can reduce the allocated memory:
Before: 56689 bytes (376 objects) After: 56291 bytes (371 objects) Diff: 398 bytes ( 5 objects)