Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
7cc8c7d2
Commit
7cc8c7d2
authored
Sep 15, 2019
by
dearblue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small improvement for mruby-io
parent
52a0ad41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
mrbgems/mruby-io/mrblib/io.rb
mrbgems/mruby-io/mrblib/io.rb
+7
-7
No files found.
mrbgems/mruby-io/mrblib/io.rb
View file @
7cc8c7d2
...
@@ -123,8 +123,8 @@ class IO
...
@@ -123,8 +123,8 @@ class IO
def
write
(
string
)
def
write
(
string
)
str
=
string
.
is_a?
(
String
)
?
string
:
string
.
to_s
str
=
string
.
is_a?
(
String
)
?
string
:
string
.
to_s
return
str
.
size
unless
str
.
size
>
0
return
0
if
str
.
empty?
if
0
<
@buf
.
length
unless
@buf
.
empty?
# reset real pos ignore buf
# reset real pos ignore buf
seek
(
pos
,
SEEK_SET
)
seek
(
pos
,
SEEK_SET
)
end
end
...
@@ -141,7 +141,7 @@ class IO
...
@@ -141,7 +141,7 @@ class IO
_check_readable
_check_readable
begin
begin
buf
=
_read_buf
buf
=
_read_buf
return
buf
.
size
==
0
return
buf
.
empty?
rescue
EOFError
rescue
EOFError
return
true
return
true
end
end
...
@@ -170,7 +170,7 @@ class IO
...
@@ -170,7 +170,7 @@ class IO
end
end
def
_read_buf
def
_read_buf
return
@buf
if
@buf
&&
@buf
.
size
>
0
return
@buf
if
@buf
&&
@buf
.
byte
size
>
0
@buf
=
sysread
(
BUF_SIZE
)
@buf
=
sysread
(
BUF_SIZE
)
end
end
...
@@ -255,12 +255,12 @@ class IO
...
@@ -255,12 +255,12 @@ class IO
if
limit
&&
limit
<=
@buf
.
size
if
limit
&&
limit
<=
@buf
.
size
array
.
push
@buf
[
0
,
limit
]
array
.
push
@buf
[
0
,
limit
]
@buf
=
@buf
[
limit
,
@buf
.
size
-
limit
]
@buf
[
0
,
limit
]
=
""
break
break
elsif
idx
=
@buf
.
index
(
rs
)
elsif
idx
=
@buf
.
index
(
rs
)
len
=
idx
+
rs
.
size
len
=
idx
+
rs
.
size
array
.
push
@buf
[
0
,
len
]
array
.
push
@buf
[
0
,
len
]
@buf
=
@buf
[
len
,
@buf
.
size
-
len
]
@buf
[
0
,
len
]
=
""
break
break
else
else
array
.
push
@buf
array
.
push
@buf
...
@@ -284,7 +284,7 @@ class IO
...
@@ -284,7 +284,7 @@ class IO
def
readchar
def
readchar
_read_buf
_read_buf
c
=
@buf
[
0
]
c
=
@buf
[
0
]
@buf
=
@buf
[
1
,
@buf
.
size
]
@buf
[
0
]
=
""
c
c
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment