Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e13b2ceaf915
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 581013920581
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Sep 13, 2016

  1. Copy the full SHA
    6c15561 View commit details
  2. Copy the full SHA
    5810139 View commit details
Showing with 9 additions and 16 deletions.
  1. +0 −11 truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
  2. +3 −3 truffle/src/main/ruby/core/io.rb
  3. +6 −2 truffle/src/main/ruby/core/string.rb
Original file line number Diff line number Diff line change
@@ -1205,17 +1205,6 @@ public Object inspect(DynamicObject string) {
}
}

@CoreMethod(names = "empty?")
public abstract static class IsEmptyNode extends CoreMethodArrayArgumentsNode {

public abstract boolean executeIsEmpty(DynamicObject string);

@Specialization
public boolean empty(DynamicObject string) {
return rope(string).isEmpty();
}
}

@CoreMethod(names = "encoding")
public abstract static class EncodingNode extends CoreMethodArrayArgumentsNode {

6 changes: 3 additions & 3 deletions truffle/src/main/ruby/core/io.rb
Original file line number Diff line number Diff line change
@@ -2583,7 +2583,7 @@ def tty?

def syswrite(data)
data = String data
return 0 if data.bytesize == 0
return 0 if data.empty?

ensure_open_and_writable
@ibuffer.unseek!(self) unless @sync
@@ -2633,7 +2633,7 @@ def ungetc(obj)

def write(data)
data = String data
return 0 if data.bytesize == 0
return 0 if data.empty?

ensure_open_and_writable

@@ -2664,7 +2664,7 @@ def write_nonblock(data)
ensure_open_and_writable

data = String data
return 0 if data.bytesize == 0
return 0 if data.empty?

@ibuffer.unseek!(self) unless @sync

8 changes: 6 additions & 2 deletions truffle/src/main/ruby/core/string.rb
Original file line number Diff line number Diff line change
@@ -142,6 +142,10 @@ def =~(pattern)
end
end

def empty?
bytesize == 0
end

def chomp(separator=$/)
str = dup
str.chomp!(separator) || str
@@ -431,7 +435,7 @@ def suffix?(other)
end

def shorten!(size)
return if bytesize == 0
return if empty?
Truffle::String.truncate(self, bytesize - size)
end

@@ -774,7 +778,7 @@ def chomp!(sep=undefined)
return
end
elsif sep.size == 0
return if bytesize == 0
return if empty?
bytes = bytesize

while i = m.previous_byte_index(bytes)