Mime sniffer: reduce table from 256 bytes to 4
The lookup table for sniffing text/plain messages for binary characters
was 256 bytes in size. The information it encoded could be stored in 32
bits.
Use a 32-bit lookup table instead of the 256-byte lookup table. This
reduces binary size.
This change is mostly performance neutral; micro-benchmarks show
no statistically significant change on Android. Micro-benchmarks on
high-performance Intel processors show an additional cost of around
400ns, apparently due to branch mis-prediction.
However, real-world performance is likely to be dominated by the time taken to
load the table into CPU cache, which the new implementation should win
easily.
Also add a micro-benchmark test.
BUG=
TEST=net_unittests
Review URL: https://codereview.chromium.org/1058003005
Cr-Commit-Position: refs/heads/master@{#330577}
diff --git a/net/BUILD.gn b/net/BUILD.gn
index ef7ed9d..85cfe20 100644
--- a/net/BUILD.gn
+++ b/net/BUILD.gn
@@ -1589,6 +1589,7 @@
executable("net_perftests") {
testonly = true
sources = [
+ "base/mime_sniffer_perftest.cc",
"cookies/cookie_monster_perftest.cc",
"disk_cache/blockfile/disk_cache_perftest.cc",
"extras/sqlite/sqlite_persistent_cookie_store_perftest.cc",