aboutsummaryrefslogtreecommitdiffstats
path: root/doc/README.developer
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2012-08-24 20:44:33 +0000
committerBill Meier <wmeier@newsguy.com>2012-08-24 20:44:33 +0000
commit0035a9076b4b5c8a14ffa67934696623a3c4bf19 (patch)
tree75587af9c72567e6d9e94fbdaec684d1b526490c /doc/README.developer
parent7d891022e647144f729fc55a62053a5c92bd02e8 (diff)
Force extended value string linear search (not binary search) in one case:
Fixed: { -2, -1, 0, 1, 3} (note gap) used a binary search (which would fail); Note: { -2, -1, 0, 1, 2 ,3 } (no gap) allowed; will still do a direct access; Also: Add a comment to README.developer extended value string section. svn path=/trunk/; revision=44659
Diffstat (limited to 'doc/README.developer')
-rw-r--r--doc/README.developer12
1 files changed, 10 insertions, 2 deletions
diff --git a/doc/README.developer b/doc/README.developer
index 600cbce8fd..02bc3b73ef 100644
--- a/doc/README.developer
+++ b/doc/README.developer
@@ -1895,9 +1895,9 @@ field would be set to NULL.
-- Extended value strings
You can also use an extended version of the value_string for faster lookups.
-It requires a value_string as input.
+It requires a value_string array as input.
If all of a contiguous range of values from min to max are present in the array
-the value will be used as as a direct index into a value_string array.
+in ascending order the value will be used as as a direct index into a value_string array.
If the values in the array are not contiguous (ie: there are "gaps"), but are
in ascending order a binary search will be used.
@@ -1905,6 +1905,14 @@ in ascending order a binary search will be used.
Note: "gaps" in a value_string array can be filled with "empty" entries eg:
{value, "Unknown"} so that direct access to the array is is possible.
+Note: the value_string array values are *unsigned*; IOW: -1 is greater than 0.
+ So:
+ { -2, -1, 1, 2 }; wrong: linear search will be used (note gap)
+ { 1, 2, -2, -1 }; correct: binary search will be used
+
+ As a special case:
+ { -2, -1, 0, 1, 2 }; OK: direct(indexed) access will be used (note no gap)
+
The init macro (see below) will perform a check on the value string the first
time it is used to determine which search algorithm fits and fall back to a
linear search if the value_string does not meet the criteria above.