scylladb / gocql

Package gocql implements a fast and robust ScyllaDB client for the Go programming language.
https://docs.scylladb.com/stable/using-scylla/drivers/cql-drivers/scylla-go-driver.html
BSD 3-Clause "New" or "Revised" License
190 stars 59 forks source link

Marshal: make const for negative int #327

Open dkropachev opened 3 weeks ago

dkropachev commented 3 weeks ago

Let's define negative sign as const and use it instead of int64(-1)<<32

func decInt64(p []byte) int64 {
    if p[0] > math.MaxInt8 {
        return int64(-1)<<32 | int64(p[0])<<24 | int64(p[1])<<16 | int64(p[2])<<8 | int64(p[3])
    }
    return int64(p[0])<<24 | int64(p[1])<<16 | int64(p[2])<<8 | int64(p[3])
}
dkropachev commented 1 week ago

@illia-li can you please take over this one.