@@ -35,9 +35,6 @@ cdef class CoreProtocol:
3535 cdef _write(self , buf):
3636 self .transport.write(memoryview(buf))
3737
38- cdef inline _write_sync_message(self ):
39- self .transport.write(SYNC_MESSAGE)
40-
4138 cdef _read_server_messages(self ):
4239 cdef:
4340 char mtype
@@ -749,14 +746,12 @@ cdef class CoreProtocol:
749746 self ._ensure_connected()
750747 self ._set_state(PROTOCOL_PREPARE)
751748
752- packet = WriteBuffer.new()
753-
754749 buf = WriteBuffer.new_message(b' P' )
755750 buf.write_str(stmt_name, self .encoding)
756751 buf.write_str(query, self .encoding)
757752 buf.write_int16(0 )
758753 buf.end_message()
759- packet.write_buffer( buf)
754+ packet = buf
760755
761756 buf = WriteBuffer.new_message(b' D' )
762757 buf.write_byte(b' S' )
@@ -766,23 +761,27 @@ cdef class CoreProtocol:
766761
767762 packet.write_bytes(SYNC_MESSAGE)
768763
769- self .transport.write(memoryview( packet) )
764+ self ._write( packet)
770765
771766 cdef _send_bind_message(self , str portal_name, str stmt_name,
772767 WriteBuffer bind_data, int32_t limit):
773768
774- cdef WriteBuffer buf
769+ cdef:
770+ WriteBuffer packet
771+ WriteBuffer buf
775772
776773 buf = self ._build_bind_message(portal_name, stmt_name, bind_data)
777- self ._write( buf)
774+ packet = buf
778775
779776 buf = WriteBuffer.new_message(b' E' )
780777 buf.write_str(portal_name, self .encoding) # name of the portal
781778 buf.write_int32(limit) # number of rows to return; 0 - all
782779 buf.end_message()
783- self ._write (buf)
780+ packet.write_buffer (buf)
784781
785- self ._write_sync_message()
782+ packet.write_bytes(SYNC_MESSAGE)
783+
784+ self ._write(packet)
786785
787786 cdef _bind_execute(self , str portal_name, str stmt_name,
788787 WriteBuffer bind_data, int32_t limit):
@@ -833,8 +832,10 @@ cdef class CoreProtocol:
833832 buf.write_str(portal_name, self .encoding) # name of the portal
834833 buf.write_int32(limit) # number of rows to return; 0 - all
835834 buf.end_message()
835+
836+ buf.write_bytes(SYNC_MESSAGE)
837+
836838 self ._write(buf)
837- self ._write_sync_message()
838839
839840 cdef _bind(self , str portal_name, str stmt_name,
840841 WriteBuffer bind_data):
@@ -845,8 +846,10 @@ cdef class CoreProtocol:
845846 self ._set_state(PROTOCOL_BIND)
846847
847848 buf = self ._build_bind_message(portal_name, stmt_name, bind_data)
849+
850+ buf.write_bytes(SYNC_MESSAGE)
851+
848852 self ._write(buf)
849- self ._write_sync_message()
850853
851854 cdef _close(self , str name, bint is_portal):
852855 cdef WriteBuffer buf
@@ -863,9 +866,10 @@ cdef class CoreProtocol:
863866
864867 buf.write_str(name, self .encoding)
865868 buf.end_message()
866- self ._write(buf)
867869
868- self ._write_sync_message()
870+ buf.write_bytes(SYNC_MESSAGE)
871+
872+ self ._write(buf)
869873
870874 cdef _simple_query(self , str query):
871875 cdef WriteBuffer buf
0 commit comments