You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The resource resolver in DevTools can cause performance degradation
during application restarts in large projects. Key methods like
isDeleted() and getAdditionalResources() rely on nested loops, leading to O(n*m) complexity.
This commit refactors ClassLoaderFiles to use a pre-computed, flattened map. This provides O(1) complexity for direct lookups and allows for efficient single-loop iteration.
The ClassLoaderFilesResourcePatternResolver is updated to leverage this new, efficient structure:
- getFile() and size() are improved from O(n) to O(1).
- isDeleted() and getAdditionalResources() are improved from O(n*m) to O(m) by eliminating nested loops.
- Data consistency is maintained across all operations.
This optimization significantly improves restart performance with a minimal memory footprint, while preserving the existing API and exception handling behavior.
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolver.java
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFiles.java
+21-12Lines changed: 21 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -43,11 +43,18 @@ public class ClassLoaderFiles implements ClassLoaderFileRepository, Serializable
0 commit comments