This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
No need for swashes for computing if ASCII
authorKarl Williamson <public@khwilliamson.com>
Sat, 24 Sep 2011 18:05:25 +0000 (12:05 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sat, 1 Oct 2011 15:58:08 +0000 (09:58 -0600)
This information is trivially computed via the macro, no need to go out
to disk and store a swash for this.

embedvar.h
intrpvar.h
perl.c
sv.c
utf8.c

index 575e2e2..f468bd8 100644 (file)
 #define PL_utf8_X_prepend      (vTHX->Iutf8_X_prepend)
 #define PL_utf8_alnum          (vTHX->Iutf8_alnum)
 #define PL_utf8_alpha          (vTHX->Iutf8_alpha)
-#define PL_utf8_ascii          (vTHX->Iutf8_ascii)
 #define PL_utf8_cntrl          (vTHX->Iutf8_cntrl)
 #define PL_utf8_digit          (vTHX->Iutf8_digit)
 #define PL_utf8_foldable       (vTHX->Iutf8_foldable)
index 84534c9..dae9b84 100644 (file)
@@ -571,7 +571,6 @@ PERLVAR(I, numeric_radix_sv, SV *)  /* The radix separator if not '.' */
 
 /* utf8 character classes */
 PERLVAR(I, utf8_alnum, SV *)
-PERLVAR(I, utf8_ascii, SV *)
 PERLVAR(I, utf8_alpha, SV *)
 PERLVAR(I, utf8_space, SV *)
 PERLVAR(I, utf8_perl_space, SV *)
diff --git a/perl.c b/perl.c
index 4285834..f0fda13 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -983,7 +983,6 @@ perl_destruct(pTHXx)
 
     /* clear utf8 character classes */
     SvREFCNT_dec(PL_utf8_alnum);
-    SvREFCNT_dec(PL_utf8_ascii);
     SvREFCNT_dec(PL_utf8_alpha);
     SvREFCNT_dec(PL_utf8_space);
     SvREFCNT_dec(PL_utf8_cntrl);
@@ -1003,7 +1002,6 @@ perl_destruct(pTHXx)
     SvREFCNT_dec(PL_utf8_idcont);
     SvREFCNT_dec(PL_utf8_foldclosures);
     PL_utf8_alnum      = NULL;
-    PL_utf8_ascii      = NULL;
     PL_utf8_alpha      = NULL;
     PL_utf8_space      = NULL;
     PL_utf8_cntrl      = NULL;
diff --git a/sv.c b/sv.c
index 6ab04da..91ccc4d 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -13210,7 +13210,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
 
     /* utf8 character classes */
     PL_utf8_alnum      = sv_dup_inc(proto_perl->Iutf8_alnum, param);
-    PL_utf8_ascii      = sv_dup_inc(proto_perl->Iutf8_ascii, param);
     PL_utf8_alpha      = sv_dup_inc(proto_perl->Iutf8_alpha, param);
     PL_utf8_space      = sv_dup_inc(proto_perl->Iutf8_space, param);
     PL_utf8_cntrl      = sv_dup_inc(proto_perl->Iutf8_cntrl, param);
diff --git a/utf8.c b/utf8.c
index 57532cb..83cc3d1 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -1236,9 +1236,7 @@ Perl_is_uni_alpha(pTHX_ UV c)
 bool
 Perl_is_uni_ascii(pTHX_ UV c)
 {
-    U8 tmpbuf[UTF8_MAXBYTES+1];
-    uvchr_to_utf8(tmpbuf, c);
-    return is_utf8_ascii(tmpbuf);
+    return isASCII(c);
 }
 
 bool
@@ -1554,7 +1552,9 @@ Perl_is_utf8_ascii(pTHX_ const U8 *p)
 
     PERL_ARGS_ASSERT_IS_UTF8_ASCII;
 
-    return is_utf8_common(p, &PL_utf8_ascii, "IsAscii");
+    /* ASCII characters are the same whether in utf8 or not.  So the macro
+     * works on both utf8 and non-utf8 representations. */
+    return isASCII(*p);
 }
 
 bool