Avoid repeated reading of file contents from disk while building stubs

This commit is contained in:
Dmitry Jemerov
2017-01-30 18:08:25 +01:00
parent 66f7382e3a
commit bc9c40883c
6 changed files with 32 additions and 23 deletions
@@ -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)
}
@@ -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