forked from forgejo/forgejo
Backport #28454 (the only conflict is caused by some comments)
* Close #24483
* Close #28123
* Close #23682
* Close #23149
(cherry picked from commit a3f403f438
)
Conflicts:
modules/setting/ui.go
trivial context conflict
This commit is contained in:
parent
c5ac659d1b
commit
cd5a0ec1c8
17 changed files with 112 additions and 148 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
package util
|
||||
|
||||
import "github.com/yuin/goldmark/util"
|
||||
import "unsafe"
|
||||
|
||||
func isSnakeCaseUpper(c byte) bool {
|
||||
return 'A' <= c && c <= 'Z'
|
||||
|
@ -83,5 +83,15 @@ func ToSnakeCase(input string) string {
|
|||
}
|
||||
}
|
||||
}
|
||||
return util.BytesToReadOnlyString(res)
|
||||
return UnsafeBytesToString(res)
|
||||
}
|
||||
|
||||
// UnsafeBytesToString uses Go's unsafe package to convert a byte slice to a string.
|
||||
// TODO: replace all "goldmark/util.BytesToReadOnlyString" with this official approach
|
||||
func UnsafeBytesToString(b []byte) string {
|
||||
return unsafe.String(unsafe.SliceData(b), len(b))
|
||||
}
|
||||
|
||||
func UnsafeStringToBytes(s string) []byte {
|
||||
return unsafe.Slice(unsafe.StringData(s), len(s))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue