From d2a3f2cedd7c00d0933222aed9c06b3149aa4db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 4 Apr 2018 13:13:37 +0200 Subject: Cowboy 2.3.0 --- articles/erlang-validate-utf8/index.html | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'articles/erlang-validate-utf8') diff --git a/articles/erlang-validate-utf8/index.html b/articles/erlang-validate-utf8/index.html index f8efb617..87e6830d 100644 --- a/articles/erlang-validate-utf8/index.html +++ b/articles/erlang-validate-utf8/index.html @@ -7,7 +7,7 @@ - + Nine Nines: Validating UTF-8 binaries with Erlang @@ -86,7 +86,7 @@ algorithm named Flexible and Economical UTF-8 Decoder. This is the C99 implementation:

-
@@ -126,7 +126,7 @@ uint32_t inline }

And this is the Erlang implementation I came up with:

-
@@ -165,7 +165,7 @@ calculate the next state. Then, the only thing we needed to be careful about was that tuples are 1-based, and that we need to stop processing the binary when we get the state 1 or when the binary is empty.

-
@@ -188,7 +188,7 @@ and State. And by write I mean generate.

the tuple ?UTF8D with its 400 elements, and then ran the following expression (after a bit of trial and error):

-
@@ -212,7 +212,7 @@ find a way to reduce its size.

clause at the end instead reduced the number to about 500, and showed that many clauses were similar:

-
@@ -226,7 +226,7 @@ http://www.gnu.org/software/src-highlite --> validate_utf8(<< 7, Rest/bits >>, 0) -> validate_utf8(Rest, 0);

But also:

-
@@ -246,7 +246,7 @@ smaller equivalents, testing that performance was not impacted, and comitting the result.

The patterns above can be found here in the resulting function:

-
@@ -268,6 +268,10 @@ http://www.gnu.org/software/src-highlite -->