Skip to content

Commit 758cea5

Browse files
committedJun 30, 2018
Use the ID string for comparison in clock_gettime logic.
1 parent 86736e3 commit 758cea5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

Diff for: ‎core/src/main/java/org/jruby/RubyProcess.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1419,15 +1419,13 @@ public static IRubyObject times(Ruby runtime) {
14191419
Block.NULL_BLOCK);
14201420
}
14211421

1422-
// this is only in 2.1. See https://bugs.ruby-lang.org/issues/8658
14231422
@JRubyMethod(module = true, visibility = PRIVATE)
14241423
public static IRubyObject clock_gettime(ThreadContext context, IRubyObject self, IRubyObject _clock_id) {
14251424
Ruby runtime = context.runtime;
14261425

14271426
return makeClockResult(runtime, getTimeForClock(_clock_id, runtime), CLOCK_UNIT_FLOAT_SECOND);
14281427
}
14291428

1430-
// this is only in 2.1. See https://bugs.ruby-lang.org/issues/8658
14311429
@JRubyMethod(module = true, visibility = PRIVATE)
14321430
public static IRubyObject clock_gettime(ThreadContext context, IRubyObject self, IRubyObject _clock_id, IRubyObject _unit) {
14331431
Ruby runtime = context.runtime;
@@ -1451,9 +1449,10 @@ private static long getTimeForClock(IRubyObject _clock_id, Ruby runtime) throws
14511449
long nanos;
14521450

14531451
if (_clock_id instanceof RubySymbol) {
1454-
if (_clock_id.toString().equals(CLOCK_MONOTONIC)) {
1452+
RubySymbol clock_id = (RubySymbol) _clock_id;
1453+
if (clock_id.idString().equals(CLOCK_MONOTONIC)) {
14551454
nanos = System.nanoTime();
1456-
} else if (_clock_id.toString().equals(CLOCK_REALTIME)) {
1455+
} else if (clock_id.idString().equals(CLOCK_REALTIME)) {
14571456
POSIX posix = runtime.getPosix();
14581457
if (posix.isNative()) {
14591458
Timeval tv = posix.allocateTimeval();
@@ -1479,9 +1478,10 @@ private static long getResolutionForClock(IRubyObject _clock_id, Ruby runtime) t
14791478
long nanos;
14801479

14811480
if (_clock_id instanceof RubySymbol) {
1482-
if (_clock_id.toString().equals(CLOCK_MONOTONIC)) {
1481+
RubySymbol clock_id = (RubySymbol) _clock_id;
1482+
if (clock_id.idString().equals(CLOCK_MONOTONIC)) {
14831483
nanos = 1;
1484-
} else if (_clock_id.toString().equals(CLOCK_REALTIME)) {
1484+
} else if (clock_id.idString().equals(CLOCK_REALTIME)) {
14851485
nanos = 1000000;
14861486
} else {
14871487
throw runtime.newErrnoEINVALError("clock_gettime");

0 commit comments

Comments
 (0)