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
|
||||
|
||||
|
||||
+2
-3
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin.reflect
|
||||
|
||||
import com.sun.xml.internal.ws.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.kotlin.load.java.structure.reflect.classId
|
||||
import org.jetbrains.kotlin.load.java.structure.reflect.desc
|
||||
import org.jetbrains.kotlin.load.java.structure.reflect.isEnumClassOrSpecializedEnumEntryClass
|
||||
@@ -61,11 +60,11 @@ class ReflectKotlinClass private constructor(
|
||||
override val classId: ClassId
|
||||
get() = klass.classId
|
||||
|
||||
override fun loadClassAnnotations(visitor: KotlinJvmBinaryClass.AnnotationVisitor) {
|
||||
override fun loadClassAnnotations(visitor: KotlinJvmBinaryClass.AnnotationVisitor, cachedContents: ByteArray?) {
|
||||
ReflectClassStructure.loadClassAnnotations(klass, visitor)
|
||||
}
|
||||
|
||||
override fun visitMembers(visitor: KotlinJvmBinaryClass.MemberVisitor) {
|
||||
override fun visitMembers(visitor: KotlinJvmBinaryClass.MemberVisitor, cachedContents: ByteArray?) {
|
||||
ReflectClassStructure.visitMembers(klass, visitor)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user