Closed binarytom closed 5 years ago
Describe the bug 在加载Interceptor时候的优化;
To Reproduce ClassScanner类中的getCicadaInterceptor方法,原实现如下:
for (Class<?> cls : clsList) { if (cls.getAnnotation(Interceptor.class) == null) { continue; } Annotation[] annotations = cls.getAnnotations(); for (Annotation annotation : annotations) { if (!(annotation instanceof Interceptor)) { continue; } Interceptor interceptor = (Interceptor) annotation; interceptorMap.put(interceptor.order(), cls); } }
建议改为:
for (Class<?> cls : clsList) { Annotation annotation = cls.getAnnotation(Interceptor.class); if (annotation == null) { continue; } Interceptor interceptor = (Interceptor) annotation; interceptorMap.put(interceptor.order(), cls); }
Expected behavior 只需要执行一次cls.getAnnotation,没有必要取第二次遍历判断。
@chosenboy
可以提交 PR 到 fix 分支。
PR
fix
@crossoverJie ok
Describe the bug 在加载Interceptor时候的优化;
To Reproduce ClassScanner类中的getCicadaInterceptor方法,原实现如下:
建议改为:
Expected behavior 只需要执行一次cls.getAnnotation,没有必要取第二次遍历判断。