Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: remove unnecessary string([]byte) conversion in fmt.Sprintf yet %s #590

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 20, 2021

  1. all: remove unnecessary string([]byte) conversion in fmt.Sprintf yet %s

    Noticed from Orijtech's continuous benchmarking product "Bencher" per
    
    https://dashboard.github.orijtech.com/benchmark/3245b8e4bbbd44a597480319aaa4b9fe
    
    that there is a bunch of code in the wild that invokes:
    
        fmt.Sprintf("%s", string([]byte(...)))
    
    yet the "%s" format specifier in fmt has a purpose:
    
        %s	the uninterpreted bytes of the string or slice
    
    which led to big improvements across every dimension:
    * CPU time reduction by 11+% (ns/op)
    * throughput improvement by 13+% (MBs/op)
    * allocations reduction by 45+% (B/op)
    * number of allocations reduction by 18+% (alloc/op)
    odeke-em committed Nov 20, 2021
    Configuration menu
    Copy the full SHA
    8c49f9b View commit details
    Browse the repository at this point in the history