diff options
author | Daniel Dragan <bulk88@hotmail.com> | 2014-09-19 17:43:11 -0400 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-09-20 07:43:23 -0700 |
commit | 3c04c629833dfd451520ff903a3eeb3f5da57fef (patch) | |
tree | ac056b422a496c473ed06484f341bf061f6f9fba /sv.c | |
parent | 7bd545ae148a40a1c2a552370bb224b64d860406 (diff) | |
download | perl-3c04c629833dfd451520ff903a3eeb3f5da57fef.tar.gz |
more factoring out in S_utf8_mg_pos_cache_update
Flip the inputs to keep_earlier, this way one 1 copy of the keep_earlier
three way square exists in machine code. Removing the float casts would
make the calculation more efficient since truncating precsion asm op dont
have to happen after every calculation but I'm not sure about side effects.
Float casts are from commit ab455f6077 with no background provided.
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -7375,6 +7375,7 @@ S_utf8_mg_pos_cache_update(pTHX_ SV *const sv, MAGIC **const mgp, const STRLEN b cache[3] = byte; } } else { +/* float casts necessary? XXX */ #define THREEWAY_SQUARE(a,b,c,d) \ ((float)((d) - (c))) * ((float)((d) - (c))) \ + ((float)((c) - (b))) * ((float)((c) - (b))) \ @@ -7401,10 +7402,18 @@ S_utf8_mg_pos_cache_update(pTHX_ SV *const sv, MAGIC **const mgp, const STRLEN b } else { const float keep_later = THREEWAY_SQUARE(0, byte, cache[1], blen); + float b, c, keep_earlier; if (byte > cache[3]) { /* New position is between the existing pair of pairs. */ - const float keep_earlier - = THREEWAY_SQUARE(0, cache[3], byte, blen); + b = cache[3]; + c = byte; + } else { + /* New position is before the existing pair of pairs. */ + b = byte; + c = cache[3]; + } + keep_earlier = THREEWAY_SQUARE(0, b, c, blen); + if (byte > cache[3]) { if (keep_later < keep_earlier) { cache[2] = utf8; cache[3] = byte; @@ -7415,9 +7424,6 @@ S_utf8_mg_pos_cache_update(pTHX_ SV *const sv, MAGIC **const mgp, const STRLEN b } } else { - /* New position is before the existing pair of pairs. */ - const float keep_earlier - = THREEWAY_SQUARE(0, byte, cache[3], blen); if (! (keep_later < keep_earlier)) { cache[0] = cache[2]; cache[1] = cache[3]; |