-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embed the public suffix database list directly inside a class #8589
base: master
Are you sure you want to change the base?
Conversation
filteringCharset = Charsets.UTF_8.toString() | ||
|
||
// TODO replace with KotlinPoet? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions welcome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since KotlinPoet generates source, this doesn't seem like a big win.
Seems to kill the kotlin compiler Maybe https://youtrack.jetbrains.com/issue/KT-72429/StackOverflowError-when-compiling-large-files or |
Base64 will added 4/3 overhead, and some decoding, but avoid issues with java class files.
I shouldn't have uncompressed it. Will compare the compressed version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll review the rest on desktop. Too dense for mobile.
@@ -9,12 +13,27 @@ plugins { | |||
id("binary-compatibility-validator") | |||
} | |||
|
|||
// Build & use okhttp3/internal/-InternalVersion.kt | |||
fun ByteArray.toByteStringExpression(): String { | |||
return "\"${Base64.getEncoder().encodeToString(this@toByteStringExpression)}\".decodeBase64()!!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like byteArrayOf
would save even more space since it would be stored raw instead of as a string that is then encoded to bytes for the classfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I'll try that. I was hitting limits of Kotlin? compiler before, with the source file like "...12, 15, -34, -56, 12..."
But let me try again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source back to 150KB, Kotlin compiler is noticeably struggling with the build. When the compile completes I'll report on the class file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've given up on that for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably worth filing a Kotlin issue if it's not fast. Although this project is stuck on old Kotlin with the old compiler, I believe.
Could also just generate package-private Java with a single static field.
One alternative is to leave the existing implementation in src/main as the default, until we get a version that we are happy with and then switch. |
Attempt a fix for #8580
Removes the need for proguard for the database. At the cost of more costly code generation at build time.
Point at which we parse the file
Generated source looks like, and both the source and class file are 57KB.