From 82b121424575fdcb8048df648614e09ee08efba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Thu, 27 Apr 2017 14:56:30 +0200 Subject: [PATCH] #inspect should not output negative object IDs. It might happen that object ID is 'negative', since Ruby tries to avoid Bignums: https://bugs.ruby-lang.org/issues/13397 --- lib/concurrent/edge/processing_actor.rb | 2 +- lib/concurrent/map.rb | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/concurrent/edge/processing_actor.rb b/lib/concurrent/edge/processing_actor.rb index f447e3edf..f9c9bca4d 100644 --- a/lib/concurrent/edge/processing_actor.rb +++ b/lib/concurrent/edge/processing_actor.rb @@ -146,7 +146,7 @@ def ask(message, answer = Promises.resolvable_future) # @return [String] string representation. def inspect - format '<#%s:0x%x termination:%s>', self.class, object_id << 1, termination.state + format '%s termination:%s>', super[0..-2], termination.state end private diff --git a/lib/concurrent/map.rb b/lib/concurrent/map.rb index f3aa55d53..34696efc0 100644 --- a/lib/concurrent/map.rb +++ b/lib/concurrent/map.rb @@ -210,12 +210,8 @@ def marshal_load(hash) undef :freeze # @!visibility private - DEFAULT_OBJ_ID_STR_WIDTH = 0.size == 4 ? 7 : 14 # we want to look "native", 7 for 32-bit, 14 for 64-bit - # override default #inspect() method: firstly, we don't want to be spilling our guts (i-vars), secondly, MRI backend's - # #inspect() call on its @backend i-var will bump @backend's iter level while possibly yielding GVL def inspect - id_str = (object_id << 1).to_s(16).rjust(DEFAULT_OBJ_ID_STR_WIDTH, '0') - "#<#{self.class.name}:0x#{id_str} entries=#{size} default_proc=#{@default_proc.inspect}>" + format '%s entries=%d default_proc=%s>', to_s[0..-2], size.to_s, @default_proc.inspect end private