From 64870af53fd78ef2007a8fe3c05639789c0ac23f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 17 May 2024 20:05:24 +0530 Subject: [PATCH] simplify logic --- tools/cmd/at/socket_io.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tools/cmd/at/socket_io.go b/tools/cmd/at/socket_io.go index 0389ad6d6..d1225c2d3 100644 --- a/tools/cmd/at/socket_io.go +++ b/tools/cmd/at/socket_io.go @@ -107,12 +107,7 @@ func run_stdin_echo_loop(conn *net.Conn, io_data *rc_io_data) (err error) { } func simple_socket_io(conn *net.Conn, io_data *rc_io_data) (serialized_response []byte, err error) { - const ( - BEFORE_FIRST_ESCAPE_CODE_SENT = iota - SENDING - ) - state := BEFORE_FIRST_ESCAPE_CODE_SENT - + first_escape_code_sent := false wants_streaming := io_data.rc.Stream for { var chunk []byte @@ -131,7 +126,8 @@ func simple_socket_io(conn *net.Conn, io_data *rc_io_data) (serialized_response if err != nil { return } - if state == BEFORE_FIRST_ESCAPE_CODE_SENT { + if !first_escape_code_sent { + first_escape_code_sent = true if wants_streaming { var streaming_response []byte streaming_response, err = read_response_from_conn(conn, io_data.timeout) @@ -143,7 +139,6 @@ func simple_socket_io(conn *net.Conn, io_data *rc_io_data) (serialized_response return } } - state = SENDING } } if io_data.rc.NoResponse {