Tnze / go-mc

Collection of Go libraries for Minecraft
https://go-mc.github.io/tutorial/
MIT License
848 stars 114 forks source link

Optimize network types IO #286

Closed layou233 closed 1 week ago

layou233 commented 2 weeks ago

Few things optimized:

  1. Use encoding/binary for binary conversions.
  2. Add CreateByteReader to avoid type assertions on every read.
  3. Improve VarInt and VarLong write. (ported from Velocity, this part of code is licensed under MIT by the author)

I've unrolled the loop for VarInt (like what Velocity has done), but kept the loop for VarLong because it's probably too long, and VarInt is used more often than VarLong. Should I also unroll it?