mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-03 22:25:57 +00:00
Use SIMD to replace C0 control codes in Go code
This commit is contained in:
parent
12c1b0cbdf
commit
fd5876b94e
10 changed files with 74 additions and 47 deletions
|
|
@ -5,7 +5,6 @@ package simdstring
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/kovidgoyal/kitty/tools/utils"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -120,13 +119,19 @@ func addressof_data(b []byte) uintptr {
|
|||
return uintptr(unsafe.Pointer(&b[0]))
|
||||
}
|
||||
|
||||
func memset(ans []byte, val byte) {
|
||||
for i := range ans {
|
||||
ans[i] = val
|
||||
}
|
||||
}
|
||||
|
||||
func aligned_slice(sz, alignment int) ([]byte, []byte) {
|
||||
ans := make([]byte, sz+alignment+512)
|
||||
a := addressof_data(ans)
|
||||
a &= uintptr(alignment - 1)
|
||||
extra := uintptr(alignment) - a
|
||||
utils.Memset(ans, '<')
|
||||
utils.Memset(ans[extra+uintptr(sz):], '>')
|
||||
memset(ans, '<')
|
||||
memset(ans[extra+uintptr(sz):], '>')
|
||||
return ans[extra : extra+uintptr(sz)], ans
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue