Avoid repeated reading of file contents from disk while building stubs
This commit is contained in:
+4
-2
@@ -67,6 +67,8 @@ abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C : Any,
|
||||
private fun ProtoContainer.Class.toBinaryClass(): KotlinJvmBinaryClass? =
|
||||
(source as? KotlinJvmBinarySourceElement)?.binaryClass
|
||||
|
||||
protected open fun getCachedFileContent(kotlinClass: KotlinJvmBinaryClass): ByteArray? = null
|
||||
|
||||
override fun loadClassAnnotations(container: ProtoContainer.Class): List<A> {
|
||||
val kotlinClass = container.toBinaryClass() ?: error("Class for loading annotations is not found: ${container.debugFqName()}")
|
||||
|
||||
@@ -79,7 +81,7 @@ abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C : Any,
|
||||
|
||||
override fun visitEnd() {
|
||||
}
|
||||
})
|
||||
}, getCachedFileContent(kotlinClass))
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -294,7 +296,7 @@ abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C : Any,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}, getCachedFileContent(kotlinClass))
|
||||
|
||||
return Storage(memberAnnotations, propertyConstants)
|
||||
}
|
||||
|
||||
+2
-2
@@ -29,9 +29,9 @@ interface KotlinJvmBinaryClass {
|
||||
*/
|
||||
val location: String
|
||||
|
||||
fun loadClassAnnotations(visitor: AnnotationVisitor)
|
||||
fun loadClassAnnotations(visitor: AnnotationVisitor, cachedContents: ByteArray?)
|
||||
|
||||
fun visitMembers(visitor: MemberVisitor)
|
||||
fun visitMembers(visitor: MemberVisitor, cachedContents: ByteArray?)
|
||||
|
||||
val classHeader: KotlinClassHeader
|
||||
|
||||
|
||||
Reference in New Issue
Block a user