Commit c7cf637f authored by Geoff Simmons's avatar Geoff Simmons

Revise the big-O claim about .match().

parent 2c73efba
...@@ -178,11 +178,12 @@ lines. For example:: ...@@ -178,11 +178,12 @@ lines. For example::
Matches with the ``.match()`` and ``.hasprefix()`` methods scale well Matches with the ``.match()`` and ``.hasprefix()`` methods scale well
as the number of strings in the set increases. The time needed for as the number of strings in the set increases. The time needed for
``.match()`` is formally O(1); for ``.hasprefix()`` it is O(*p*), ``.match()`` is formally O(*l*), where *l* is the length of the
where *p* is the length of the longest string in the set that forms a subject string (the string to be matched). For ``.hasprefix()`` it is
prefix of the string to be matched. In both cases, the number of O(*p*), where *p* is the length of the longest string in the set that
execution steps is independent of the number of strings in the set, forms a prefix of the subject. In both cases, the number of execution
and is predictable and fast for large sets of strings. steps is independent of the number of strings in the set, and is
predictable and fast for large sets of strings.
When new strings are added to a set (with new ``.add()`` statements in When new strings are added to a set (with new ``.add()`` statements in
``vcl_init``), the VCL code that executes the various operations ``vcl_init``), the VCL code that executes the various operations
......
...@@ -174,11 +174,12 @@ lines. For example:: ...@@ -174,11 +174,12 @@ lines. For example::
Matches with the ``.match()`` and ``.hasprefix()`` methods scale well Matches with the ``.match()`` and ``.hasprefix()`` methods scale well
as the number of strings in the set increases. The time needed for as the number of strings in the set increases. The time needed for
``.match()`` is formally O(1); for ``.hasprefix()`` it is O(*p*), ``.match()`` is formally O(*l*), where *l* is the length of the
where *p* is the length of the longest string in the set that forms a subject string (the string to be matched). For ``.hasprefix()`` it is
prefix of the string to be matched. In both cases, the number of O(*p*), where *p* is the length of the longest string in the set that
execution steps is independent of the number of strings in the set, forms a prefix of the subject. In both cases, the number of execution
and is predictable and fast for large sets of strings. steps is independent of the number of strings in the set, and is
predictable and fast for large sets of strings.
When new strings are added to a set (with new ``.add()`` statements in When new strings are added to a set (with new ``.add()`` statements in
``vcl_init``), the VCL code that executes the various operations ``vcl_init``), the VCL code that executes the various operations
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment