5db5bc0c7e
Added eight database indices. Fixed a bug where the second tick wouldn't fire. Tweaked the .topic_forum in Nox by a pixel. Replaced some _installer strings with blank strings for consistency with the builders. Greatly reduced the number of allocations in the user agent parser. Added ampersand entities in more attachment URLs to avoid accidental mangling. .edit_source is now hidden for guests. Guest noavatars are now pre-calculated to reduce the number of allocations. Lazily initialised a couple of maps in ViewTopic to reduce the number of unnecessary allocations slightly. Added the unsafe BytesToString function. Please don't use this, if you don't have to. Added the AddIndex method to the adapter and associated components. Added the /reply/attach/add/submit/ route. Added the /reply/attach/remove/submit/ route. Added the topic_alt_userinfo template. Replaced Attachments.MiniTopicGet with MiniGetList. Added Attachments.BulkMiniGetList. Added a quick test for ReplyStore.Create. Added BenchmarkPopulateTopicWithRouter. Added BenchmarkTopicAdminFullPageRouteParallelWithRouter. Added BenchmarkTopicGuestFullPageRouteParallelWithRouter. You will need to run the updater or patcher for this commit.
35 lines
688 B
Go
35 lines
688 B
Go
package main
|
|
|
|
import (
|
|
"reflect"
|
|
"runtime"
|
|
"unsafe"
|
|
)
|
|
|
|
var GetFrag = func(name string) [][]byte {
|
|
return nil
|
|
}
|
|
|
|
type WriteString interface {
|
|
WriteString(s string) (n int, err error)
|
|
}
|
|
|
|
func StringToBytes(s string) (bytes []byte) {
|
|
str := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
|
slice := (*reflect.SliceHeader)(unsafe.Pointer(&bytes))
|
|
slice.Data = str.Data
|
|
slice.Len = str.Len
|
|
slice.Cap = str.Len
|
|
runtime.KeepAlive(&s)
|
|
return bytes
|
|
}
|
|
|
|
func BytesToString(bytes []byte) (s string) {
|
|
slice := (*reflect.SliceHeader)(unsafe.Pointer(&bytes))
|
|
str := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
|
str.Data = slice.Data
|
|
str.Len = slice.Len
|
|
runtime.KeepAlive(&bytes)
|
|
return s
|
|
}
|