mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: remove unnecessary IError() casts
This commit is contained in:
@ -38,21 +38,21 @@ pub fn new_buffered_reader(o BufferedReaderConfig) &BufferedReader {
|
||||
// read fufills the Reader interface
|
||||
pub fn (mut r BufferedReader) read(mut buf []u8) !int {
|
||||
if r.end_of_stream {
|
||||
return IError(Eof{})
|
||||
return Eof{}
|
||||
}
|
||||
// read data out of the buffer if we dont have any
|
||||
if r.needs_fill() {
|
||||
if !r.fill_buffer() {
|
||||
// end of stream
|
||||
return IError(Eof{})
|
||||
return Eof{}
|
||||
}
|
||||
}
|
||||
read := copy(mut buf, r.buf[r.offset..r.len])
|
||||
if read == 0 {
|
||||
return IError(NotExpected{
|
||||
return NotExpected{
|
||||
cause: 'invalid copy of buffer'
|
||||
code: -1
|
||||
})
|
||||
}
|
||||
}
|
||||
r.offset += read
|
||||
return read
|
||||
|
@ -15,7 +15,7 @@ fn (mut s StringReader) read(mut buf []u8) !int {
|
||||
eprintln('>>>> StringReader.read output buf.len: $buf.len')
|
||||
}
|
||||
if s.place > s.text.len + 1 {
|
||||
return IError(io.Eof{})
|
||||
return io.Eof{}
|
||||
}
|
||||
mut howmany := imin(buf.len, s.text.len - s.place)
|
||||
xxx := s.text[s.place..s.place + howmany].bytes()
|
||||
|
@ -14,7 +14,7 @@ pub mut:
|
||||
|
||||
fn (mut b Buf) read(mut buf []u8) !int {
|
||||
if !(b.i < b.bytes.len) {
|
||||
return IError(io.Eof{})
|
||||
return io.Eof{}
|
||||
}
|
||||
n := copy(mut buf, b.bytes[b.i..])
|
||||
b.i += n
|
||||
|
@ -9,7 +9,7 @@ mut:
|
||||
|
||||
fn (mut b Buf) read(mut buf []u8) !int {
|
||||
if !(b.i < b.bytes.len) {
|
||||
return IError(Eof{})
|
||||
return Eof{}
|
||||
}
|
||||
n := copy(mut buf, b.bytes[b.i..])
|
||||
b.i += n
|
||||
@ -46,7 +46,7 @@ mut:
|
||||
|
||||
fn (mut s StringReader) read(mut buf []u8) !int {
|
||||
if s.place >= s.text.len {
|
||||
return IError(Eof{})
|
||||
return Eof{}
|
||||
}
|
||||
read := copy(mut buf, s.text[s.place..].bytes())
|
||||
s.place += read
|
||||
|
Reference in New Issue
Block a user