-
Notifications
You must be signed in to change notification settings - Fork 129
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
Expose ICUs u_hasBinaryProperty #1029
Conversation
internal fun Int.charCount(): Int = if (this >= MIN_SUPPLEMENTARY_CODE_POINT) 2 else 1 | ||
|
||
internal val String.codePointsAsIntArray: IntArray | ||
get() = codePoints.toList().toIntArray() |
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.
Doesn't it create an extra copy?
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.
It does (actually more than once, inside toList()
), but it's not easy to avoid this copy, as the number of codepoints is not known upfront. And if we just return List<Int>
here, the callers will still need to convert it to an int array.
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.
LGTM, just a few nitpicks
internal val String.codePoints | ||
get() = codePointsAt(0) | ||
|
||
internal fun String.codePointsAt(index: Int) = sequence { |
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.
The code in CharHelpers.skiko.kt
mentioned is actually like:
internal val String.codePoints | |
get() = codePointsAt(0) | |
internal fun String.codePointsAt(index: Int) = sequence { | |
internal val CharSequence.codePoints get() = sequence { |
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.
Yes, the copy is after my changes in JetBrains/compose-multiplatform-core#1869
This is more generic and is not worse, so why change it?
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.
String
/CharSequence
consistency
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.
We have it in more than one place; the one I copied it from uses String
, but sure, CharSequence
is better.
} | ||
|
||
@Suppress("MemberVisibilityCanBePrivate", "unused", "SpellCheckingInspection") | ||
object CharProperties { |
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.
Missing KDoc for public API
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.
Added.
|
||
@ExternalSymbolName("org_jetbrains_skia_icu_Unicode_nCodePointHasBinaryProperty") | ||
@ModuleImport("./skiko.mjs", "org_jetbrains_skia_icu_Unicode_nCodePointHasBinaryProperty") | ||
private external fun nCodePointHasBinaryProperty(codePoint: Int, property: Int): Boolean |
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.
Let's keep prefixes consistent (one way or another)
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.
Changed.
@m-sasha you forgot to push the changes, right? |
fcddfc7
to
28f117d
Compare
Yes, sorry, pushed now. |
This is needed to detect emojis in Compose Multiplatform.
Also, it looks like the native implementations of
String.intCodePoints()
were broken. I fixed them by copying the relevant code from Compose.