Skip to content

Commit f23c205

Browse files
committed
Small tidy up.
1 parent 291ded2 commit f23c205

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/main/java/org/truffleruby/core/thread/ThreadLocalBuffer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
public final class ThreadLocalBuffer {
1818

1919
public static final ThreadLocalBuffer NULL_BUFFER = new ThreadLocalBuffer(new Pointer(0, 0), null);
20+
private static final long ALIGNMENT = 8L;
21+
private static final long ALIGNMENT_MASK = ALIGNMENT - 1;
2022

2123
public final Pointer start;
2224
long remaining;
2325
private final ThreadLocalBuffer parent;
24-
private final long ALIGNMENT = 8L;
25-
private final long ALIGNMENT_MASK = ALIGNMENT - 1;
2626

2727
private ThreadLocalBuffer(Pointer start, ThreadLocalBuffer parent) {
2828
this.start = start;
@@ -90,7 +90,7 @@ public Pointer allocate(RubyThread thread, long size, ConditionProfile allocatio
9090
}
9191
}
9292

93-
private long alignUp(long size) {
93+
private static long alignUp(long size) {
9494
return (size + ALIGNMENT_MASK) & ~ALIGNMENT_MASK;
9595
}
9696

src/main/ruby/truffleruby/core/io.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ def fill(io, max = DEFAULT_READ_SIZE)
142142
count = Primitive.min(unused, max)
143143

144144
total_read = 0
145-
Truffle::POSIX.read_to_buffer_at_least_one_byte(io, count) do |buffer, bytes_read|
145+
Truffle::POSIX.read_to_buffer_at_least_one_byte(io, count) do |pointer, bytes_read|
146146
# Detect if another thread has updated the buffer
147147
# and now there isn't enough room for this data.
148148
if bytes_read > unused
149149
raise RuntimeError, 'internal implementation error - IO buffer overrun'
150150
end
151-
Primitive.pointer_read_bytes_to_byte_array(@storage, @used, buffer.address, bytes_read)
151+
Primitive.pointer_read_bytes_to_byte_array(@storage, @used, pointer.address, bytes_read)
152152
@used += bytes_read
153153
total_read += bytes_read
154154
end
@@ -1266,9 +1266,8 @@ def read_to_separator_with_limit
12661266
def read_all
12671267
str = +''
12681268
unless @buffer.exhausted?
1269-
if !(tmp_str = @buffer.shift).empty?
1270-
str << tmp_str
1271-
end
1269+
tmp_str = @buffer.shift
1270+
str << tmp_str unless tmp_str.empty?
12721271
end
12731272

12741273
while (tmp_str = Truffle::POSIX.read_string_at_least_one_byte(@io, InternalBuffer::DEFAULT_READ_SIZE))

src/main/ruby/truffleruby/core/posix.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ def self.read_string_at_least_one_byte(io, count)
362362
end
363363
end
364364

365+
# Read up to count bytes of io to the thread-local IO buffer, and
366+
# yields the buffer (a FFI::Pointer) and bytes_read
365367
def self.read_to_buffer_at_least_one_byte(io, count, &block)
366368
while true
367369
# must call #read_to_buffer in order to properly support polyglot STDIO

0 commit comments

Comments
 (0)