Mime sniffer: reduce table from 256 bytes to 4
commit10eb9f5e836087e3c0324043221d217af56d30e2
authorricea <ricea@chromium.org>
Tue, 19 May 2015 18:51:57 +0000 (19 11:51 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 19 May 2015 18:52:59 +0000 (19 18:52 +0000)
treee860dcf14a39e6fb6f29733e0ede458cc0ad1894
parent41b04f38c37575dc66db8a6036be62f51adff209
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}
net/BUILD.gn
net/base/mime_sniffer.cc
net/base/mime_sniffer.h
net/base/mime_sniffer_perftest.cc [new file with mode: 0644]
net/base/mime_sniffer_unittest.cc
net/net.gyp