diff --git a/core/buffered_reader.go b/core/buffered_reader.go index fce3d119a..508f1438d 100644 --- a/core/buffered_reader.go +++ b/core/buffered_reader.go @@ -13,11 +13,9 @@ type ( } ) -func MakeBufferedReader(rd io.Reader, hash uint32) *BufferedReader { - res := &BufferedReader{bufio.NewReader(rd), hash} - if hash == 0 { - res.hash = HashPtr(uintptr(unsafe.Pointer(res))) - } +func MakeBufferedReader(rd io.Reader) *BufferedReader { + res := &BufferedReader{bufio.NewReader(rd), 0} + res.hash = HashPtr(uintptr(unsafe.Pointer(res))) return res } diff --git a/core/environment.go b/core/environment.go index 6fb2adf14..95eb67419 100644 --- a/core/environment.go +++ b/core/environment.go @@ -72,10 +72,6 @@ func (env *Env) SetClassPath(cp string) { env.classPath.Value = cpVec } -const stdinHashValue uint32 = 0x1fc542bb -const stdoutHashValue uint32 = 0xef3ebf05 -const stderrHashValue uint32 = 0xbfa32704 - func NewEnv(currentNs Symbol, stdin io.Reader, stdout io.Writer, stderr io.Writer) *Env { features := EmptySet() features.Add(MakeKeyword("default")) @@ -91,11 +87,11 @@ func NewEnv(currentNs Symbol, stdin io.Reader, stdout io.Writer, stderr io.Write res.ns = res.CoreNamespace.Intern(MakeSymbol("*ns*")) res.ns.Value = res.EnsureNamespace(currentNs) res.stdin = res.CoreNamespace.Intern(MakeSymbol("*in*")) - res.stdin.Value = MakeBufferedReader(stdin, stdinHashValue) + res.stdin.Value = MakeBufferedReader(stdin) res.stdout = res.CoreNamespace.Intern(MakeSymbol("*out*")) - res.stdout.Value = MakeIOWriter(stdout, stdoutHashValue) + res.stdout.Value = MakeIOWriter(stdout) res.stderr = res.CoreNamespace.Intern(MakeSymbol("*err*")) - res.stderr.Value = MakeIOWriter(stderr, stderrHashValue) + res.stderr.Value = MakeIOWriter(stderr) res.file = res.CoreNamespace.Intern(MakeSymbol("*file*")) res.MainFile = res.CoreNamespace.Intern(MakeSymbol("*main-file*")) res.version = res.CoreNamespace.InternVar("*joker-version*", versionMap(), diff --git a/core/io_writer.go b/core/io_writer.go index d45da1162..69f0ad48e 100644 --- a/core/io_writer.go +++ b/core/io_writer.go @@ -12,11 +12,9 @@ type ( } ) -func MakeIOWriter(w io.Writer, hash uint32) *IOWriter { - res := &IOWriter{w, hash} - if hash == 0 { - res.hash = HashPtr(uintptr(unsafe.Pointer(res))) - } +func MakeIOWriter(w io.Writer) *IOWriter { + res := &IOWriter{w, 0} + res.hash = HashPtr(uintptr(unsafe.Pointer(res))) return res } diff --git a/core/procs.go b/core/procs.go index 5f0a798cc..71e2aad3f 100644 --- a/core/procs.go +++ b/core/procs.go @@ -1344,7 +1344,7 @@ var procBuffer Proc = func(args []Object) Object { var procBufferedReader Proc = func(args []Object) Object { switch rdr := args[0].(type) { case io.Reader: - return MakeBufferedReader(rdr, 0) + return MakeBufferedReader(rdr) default: panic(RT.NewArgTypeError(0, args[0], "IOReader")) } diff --git a/main.go b/main.go index 9f437423f..f069b111d 100644 --- a/main.go +++ b/main.go @@ -196,8 +196,8 @@ func srepl(port string, phase Phase) { Stdin = conn Stdout = conn Stderr = conn - newIn := MakeBufferedReader(conn, 0) - newOut := MakeIOWriter(conn, 0) + newIn := MakeBufferedReader(conn) + newOut := MakeIOWriter(conn) GLOBAL_ENV.SetStdIO(newIn, newOut, newOut) defer func() { conn.Close() diff --git a/tests/eval/hash.joke b/tests/eval/hash.joke index a23d75339..5b8f3527e 100644 --- a/tests/eval/hash.joke +++ b/tests/eval/hash.joke @@ -16,8 +16,4 @@ (is (= (hash :hey) 819820356)) (is (= (hash :there) 1648208352)) (is (= (hash ::you) 3944753178)) - (is (= (hash :user/foo) 1616868817))) - (testing "stable stdio hashes" - (is (= (hash *in*) 533021371)) - (is (= (hash *out*) 4013866757)) - (is (= (hash *err*) 3215140612)))) + (is (= (hash :user/foo) 1616868817))))