Git Product home page Git Product logo

Comments (3)

egonelbre avatar egonelbre commented on June 20, 2024 1

I meant the var buffer [64]byte version. Take a look at https://go.dev/play/p/0ig2yQgA3gg.

Benchmark results:

name              time/op
Append_Pooled-32  214ns ± 5%
Append_Stack-32   202ns ± 1%
Append_Alloc-32   201ns ± 0%

Also, avoiding the pool is also going to less code and easier to reason about.

While reviewing the code, I realized that that it's always putting back the small slice, so there's no problem with holding on to a potentially large slices.

from mpb.

vbauerster avatar vbauerster commented on June 20, 2024

I was looking through the codebase and when running staticcheck it lists these issues:

Yep, staticcheck's suggestion is right, despite current behavior doesn't lead to any bugs.

Other things I noticed that aren't errors per se, but looked unusual to me:

Thankfully I left a comment strip off nanoseconds. I agree that Truncate func is better option here, thanks for suggestion.

using a var buffer [64]byte should get you most of the way and avoid scenarios where you accidentally pool large []byte values for a long time.

It's used to feed strconv.AppendFloat with dst []byte param. Did you mean to increase cap to 64 like b := make([]byte, 0, 64) or using array [64]byte instead of slice? If latter then how can it help/improve?

from mpb.

vbauerster avatar vbauerster commented on June 20, 2024

Addressed in v8.4.0.

from mpb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.