Skip to content
Snippets Groups Projects
Commit 015f4328 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Unicode: Optimize normalize() in NFC mode on 8-bit strings.

Unicode.normalize() in NFS mode on 8-bit strings is a noop,
so there's no need to scan though the string.

Fixes [PIKE-79].
parent 6178ca97
No related branches found
No related tags found
No related merge requests found
...@@ -634,7 +634,6 @@ testfont binary ...@@ -634,7 +634,6 @@ testfont binary
/src/post_modules/Unicode/acconfig.h foreign_ident /src/post_modules/Unicode/acconfig.h foreign_ident
/src/post_modules/Unicode/buffer.c foreign_ident /src/post_modules/Unicode/buffer.c foreign_ident
/src/post_modules/Unicode/configure.in foreign_ident /src/post_modules/Unicode/configure.in foreign_ident
/src/post_modules/Unicode/normalize.c foreign_ident
/src/post_modules/Unicode/split.c foreign_ident /src/post_modules/Unicode/split.c foreign_ident
/src/post_modules/Unicode/unicode_module.cmod foreign_ident /src/post_modules/Unicode/unicode_module.cmod foreign_ident
/src/post_modules/configure.in foreign_ident /src/post_modules/configure.in foreign_ident
......
#include "global.h" #include "global.h"
#include "stralloc.h" #include "stralloc.h"
#include "global.h" #include "global.h"
RCSID("$Id: normalize.c,v 1.7 2001/11/22 14:52:18 grubba Exp $"); RCSID("$Id$");
#include "pike_macros.h" #include "pike_macros.h"
#include "interpret.h" #include "interpret.h"
#include "program.h" #include "program.h"
...@@ -276,7 +276,14 @@ struct pike_string *unicode_normalize( struct pike_string *source, ...@@ -276,7 +276,14 @@ struct pike_string *unicode_normalize( struct pike_string *source,
return source; return source;
} }
/* What, me lisp? */ /* What, me lisp? */
if( how & COMPOSE_BIT ) if( how & COMPOSE_BIT ) {
if (!source->size_shift && !(how & COMPAT_BIT)) {
/* NB: There are 8-bit characters that are changed in
* compat mode; eg NBSP (0xA0) and DIAERESIS (0xA8).
*/
add_ref(source);
return source;
}
return return
uc_buffer_to_pikestring( uc_buffer_to_pikestring(
unicode_compose_buffer( unicode_compose_buffer(
...@@ -286,6 +293,7 @@ struct pike_string *unicode_normalize( struct pike_string *source, ...@@ -286,6 +293,7 @@ struct pike_string *unicode_normalize( struct pike_string *source,
source ), source ),
how ), how ),
how ) ); how ) );
}
return return
uc_buffer_to_pikestring( uc_buffer_to_pikestring(
unicode_decompose_buffer( unicode_decompose_buffer(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment