aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2023-03-13 18:31:30 +0800
committerPo Lu2023-03-13 18:31:30 +0800
commite6186b6a2a452f555ab024d1fc770683561ac024 (patch)
tree85e5f1580aa310ff7a8c1b603da69184e94d1db0 /src
parentd3bb4b668755ae257bc00006d0806122cf7d7bf1 (diff)
downloademacs-e6186b6a2a452f555ab024d1fc770683561ac024.tar.gz
emacs-e6186b6a2a452f555ab024d1fc770683561ac024.zip
Update Android port
* src/android.c (android_check_string, android_build_string): Reduce consing when building menu bar strings.
Diffstat (limited to 'src')
-rw-r--r--src/android.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/android.c b/src/android.c
index 16c645ced1e..efbf8fc95cc 100644
--- a/src/android.c
+++ b/src/android.c
@@ -5389,6 +5389,23 @@ emacs_abort (void)
5389 5389
5390 5390
5391 5391
5392/* Return whether or not TEXT, a string without multibyte
5393 characters, has no bytes with the 8th bit set. */
5394
5395static bool
5396android_check_string (Lisp_Object text)
5397{
5398 ptrdiff_t i;
5399
5400 for (i = 0; i < ASIZE (text); ++i)
5401 {
5402 if (SREF (text, i) & 128)
5403 return false;
5404 }
5405
5406 return true;
5407}
5408
5392/* Given a Lisp string TEXT, return a local reference to an equivalent 5409/* Given a Lisp string TEXT, return a local reference to an equivalent
5393 Java string. */ 5410 Java string. */
5394 5411
@@ -5401,6 +5418,21 @@ android_build_string (Lisp_Object text)
5401 jchar *characters; 5418 jchar *characters;
5402 USE_SAFE_ALLOCA; 5419 USE_SAFE_ALLOCA;
5403 5420
5421 /* Directly encode TEXT if it contains no multibyte
5422 characters. This is okay because the Java extended UTF
5423 format is compatible with ASCII. */
5424
5425 if (SBYTES (text) == SCHARS (text)
5426 && android_check_string (text))
5427 {
5428 string = (*android_java_env)->NewStringUTF (android_java_env,
5429 SSDATA (text));
5430 android_exception_check ();
5431 SAFE_FREE ();
5432
5433 return string;
5434 }
5435
5404 encoded = code_convert_string_norecord (text, Qutf_16le, 5436 encoded = code_convert_string_norecord (text, Qutf_16le,
5405 true); 5437 true);
5406 nchars = (SBYTES (encoded) / sizeof (jchar)); 5438 nchars = (SBYTES (encoded) / sizeof (jchar));