Skip to content

Commit

Permalink
Slight readability simplification around eligible friends.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 705510751
  • Loading branch information
gkdn authored and copybara-github committed Dec 12, 2024
1 parent b0971ac commit d637f50
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ internal fun K2JVMCompilerArguments.setEligibleFriends(currentTarget: String?) {
.split(":")
.filter {
val depPath = Path.of(it)
val depLabel = useManifestFast(depPath) { it.targetLabel } ?: return@filter false
val depLabel = getLabelFromManifest(depPath) ?: return@filter false
AutoFriends.isEligibleFriend(currentLabel, depLabel)
}
.toTypedArray()
}

private fun <T> useManifestFast(path: Path, block: (KtManifest) -> T): T? {
private fun getLabelFromManifest(path: Path): BzlLabel? {
return JarInputStream(BufferedInputStream(Files.newInputStream(path)), /* verify= */ false).use {
jar ->
jar.manifest?.let { block(KtManifest(it)) }
jar.manifest?.let { KtManifest(it).targetLabel }
}
}

Expand Down

0 comments on commit d637f50

Please sign in to comment.