• ricea's avatar
    Mime sniffer: reduce table from 256 bytes to 4 · 10eb9f5e
    ricea authored
    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}
    10eb9f5e
mime_sniffer_unittest.cc 20.8 KB