Skip to content

Commit

Permalink
better wording
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Mar 20, 2024
1 parent c64f634 commit 5df2c5e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions include/ada/scheme-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ constexpr uint16_t special_ports[] = {80, 0, 443, 80, 21, 443, 0, 0};

/****
* In is_special, get_scheme_type, and get_special_port, we
* use a standard hashing technique to find the index of the scheme in the
* is_special_list. The hashing technique is based on the size of the scheme
* and the first character of the scheme. It ensures that we do at most one
* string comparison per call. If the protocol is predictible (e.g., it is
* always "http"), we can get a better average performance by using a a
* simpler approach where we loop and compare scheme with all possible
* protocol. In this instance, we choose a potentially slightly lower
* best-case performance for a better worst-case performance.
* use a standard hashing technique to find the index of the scheme in
* the is_special_list. The hashing technique is based on the size of
* the scheme and the first character of the scheme. It ensures that we
* do at most one string comparison per call. If the protocol is
* predictible (e.g., it is always "http"), we can get a better average
* performance by using a simpler approach where we loop and compare
* scheme with all possible protocols starting with the most likely
* protocol. Doing multiple comparisons may have a poor worst case
* performance, however. In this instance, we choose a potentially slightly
* lower best-case performance for a better worst-case performance.
* We can revisit this choice at any time.
*
* Reference:
* Schmidt, Douglas C. "Gperf: A perfect hash function generator." More C++
Expand Down

0 comments on commit 5df2c5e

Please sign in to comment.