|
return db.dB.Put([]byte(fmt.Sprintf("%s.%s", table, key)), []byte(strconv.Itoa(i)), nil) |
As you see, we could be storing the integer as raw bytes, but instead we're converting it to a string representation first for some reason.
I believe (*[unsafe.Sizeof(i)]byte)(unsafe.Pointer(&i)) should do the trick.
It will need to be rolled out with some sort of database upgrade ... as old numbers will be stored completely differently. Figuring out how to roll this out is the hardest part, but considering OneBot is supposed to be considered unstable, a warning could be enough... (users could always downgrade if an upgrade breaks their kit anyhow)
onebot/onelib/leveldb.go
Line 79 in b11327e
As you see, we could be storing the integer as raw bytes, but instead we're converting it to a string representation first for some reason.
I believe
(*[unsafe.Sizeof(i)]byte)(unsafe.Pointer(&i))should do the trick.It will need to be rolled out with some sort of database upgrade ... as old numbers will be stored completely differently. Figuring out how to roll this out is the hardest part, but considering OneBot is supposed to be considered unstable, a warning could be enough... (users could always downgrade if an upgrade breaks their kit anyhow)