diff options
author | Karl Williamson <public@khwilliamson.com> | 2012-08-23 13:47:37 -0600 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2012-08-25 23:21:28 -0600 |
commit | 15896d2f753bef49b0736f497e92161d548b0a87 (patch) | |
tree | 55c5cd3064622292078ea6d03e95bce3f68d617d /inline_invlist.c | |
parent | f0fdc1c93fe4410df3f4f4d0c836005cec3b7f55 (diff) | |
download | perl-15896d2f753bef49b0736f497e92161d548b0a87.tar.gz |
Add caching to inversion list searches
Benchmarking showed some speed-up when the result of the previous
search in an inversion list is cached, thus potentially avoiding a
search in the next call. This adds a field to each inversion list which
caches its previous search result.
Diffstat (limited to 'inline_invlist.c')
-rw-r--r-- | inline_invlist.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/inline_invlist.c b/inline_invlist.c index 80a6898e42..bb5ec17a9b 100644 --- a/inline_invlist.c +++ b/inline_invlist.c @@ -15,6 +15,8 @@ #define INVLIST_LEN_OFFSET 0 /* Number of elements in the inversion list */ #define INVLIST_ITER_OFFSET 1 /* Current iteration position */ +#define INVLIST_PREVIOUS_INDEX_OFFSET 2 /* Place to cache index of previous + result */ /* This is a combination of a version and data structure type, so that one * being passed in can be validated to be an inversion list of the correct @@ -22,13 +24,13 @@ * in the range 2**31-1 should be generated and the new() method changed to * insert that at this location. Then, if an auxiliary program doesn't change * correspondingly, it will be discovered immediately */ -#define INVLIST_VERSION_ID_OFFSET 2 -#define INVLIST_VERSION_ID 1064334010 +#define INVLIST_VERSION_ID_OFFSET 3 +#define INVLIST_VERSION_ID 290655244 /* For safety, when adding new elements, remember to #undef them at the end of * the inversion list code section */ -#define INVLIST_ZERO_OFFSET 3 /* 0 or 1; must be last element in header */ +#define INVLIST_ZERO_OFFSET 4 /* 0 or 1; must be last element in header */ /* The UV at position ZERO contains either 0 or 1. If 0, the inversion list * contains the code point U+00000, and begins here. If 1, the inversion list * doesn't contain U+0000, and it begins at the next UV in the array. |