summaryrefslogtreecommitdiff
path: root/ioutil.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-01-26 21:02:56 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-01-30 22:00:25 -0700
commit2828fa21c0ffd2a32a108b37c0417b01abc42929 (patch)
treeae671b894fa952e01a410c94fe27e1d0fec37e80 /ioutil.go
parent8aa12d3cb043859229810947da6c52e600d34b55 (diff)
Avoid doing type switching in inner functions
The CPU profiler tells me that the encoder is spending a lot of time on type switches.
Diffstat (limited to 'ioutil.go')
-rw-r--r--ioutil.go31
1 files changed, 0 insertions, 31 deletions
diff --git a/ioutil.go b/ioutil.go
deleted file mode 100644
index a53eac3..0000000
--- a/ioutil.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com>
-//
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-package lowmemjson
-
-import (
- "io"
- "unicode/utf8"
-)
-
-func writeByte(w io.Writer, c byte) error {
- if br, ok := w.(interface{ WriteByte(byte) error }); ok {
- return br.WriteByte(c)
- }
- var buf [1]byte
- buf[0] = c
- if _, err := w.Write(buf[:]); err != nil {
- return err
- }
- return nil
-}
-
-func writeRune(w io.Writer, c rune) (int, error) {
- if rw, ok := w.(interface{ WriteRune(rune) (int, error) }); ok {
- return rw.WriteRune(c)
- }
- var buf [utf8.UTFMax]byte
- n := utf8.EncodeRune(buf[:], c)
- return w.Write(buf[:n])
-}