Diff

Differences From Artifact [c84493a1fe]:

To Artifact [9862ea3396]:


103
104
105
106
107
108
109
110

111
112
113
114
115
116
117

118
119
120
121
122
123
124
103
104
105
106
107
108
109

110
111
112
113
114
115
116

117
118
119
120
121
122
123
124







-
+






-
+







	var (
		count int
		err   error
	)

start:
	// Reply with the buffered data if there is any
	if sr.to-sr.from > 0 {
	if sr.to > 0 {
		count = copy(output, sr.buffer[sr.from:sr.to])

		// Advance the data in the buffer
		sr.from += count

		// Check whether we have reached the end of the buffer
		if sr.to-sr.from == 0 {
		if sr.from == sr.to {
			// Reset the buffer
			sr.from, sr.to = 0, 0

			return count, err
		}

		// Do not propagate an error until the buffer is exhausted
132
133
134
135
136
137
138
139

140
141
142
143
144
145
132
133
134
135
136
137
138

139
140
141
142
143
144
145







-
+







	// Perform a read into the buffer
	count, err = sr.reader.Read(sr.buffer)

	// Size the buffer down to the read data size
	// and restart if we have successfully read some bytes
	sr.from, sr.to = 0, count
	if sr.to-sr.from > 0 {
	if sr.to > 0 {
		goto start
	}

	// Returning on err/misbehaving noop reader
	return 0, err
}