HTTPS clone URL
Subversion checkout URL
Please sign in to comment.
Fix reflection warnings
Reflection can be a useful tool for achieving polymorphism when methods do not adhere to a well-defined interface or class hierarchy. It is also quite expensive (and the warnings generated with *warn-on-reflection* are very ugly) so its use should be justified. Slamhound's use of reflection is unnecessary, so this patch resolves all reflection warnings in the project. First, we replace .trim and .split calls to their clojure.string equivalents. This actually increases flexibility at no appreciable cost. Next we add type hints for static dispatch. Most of these hints are actually beneficial for clarity, but one function's type signature was implicitly changed: -(defn clj? [f] - (.endsWith (.getName f) ".clj")) +(defn clj? [^String path] + (.endsWith path ".clj")) I don't believe this will cause any problems as it is unlikely that anyone has been tempted to use this function outside of slamhound. This function, as well as most functions within slam.hound.search, are good candidates for being made private. Most of the dynamic method calls dealt with organizing classes from jar files, so there has been a corresponding performance increase for reconstructing namespaces that use many imports. For instance, reconstructing slam.hound.search is now ~20% faster. The function slam.hound.search/namespaces-from-jars is a full ~100% faster. Preloading speed and alias/refer reconstruction performance has not been noticeably affected.
- Loading branch information...
Showing with 33 additions and 32 deletions.