[Groonga-commit] droonga/droonga-engine at f9114cc [master] Discard old live nodes list

Back to archive index

YUKI Hiroshi yuki****@clear*****
Thu May 8 17:33:06 JST 2014


Hash#key?(key) は存在を知りませんでした。ありがとうございます。

Kouhei Sutou wrote:
>> +    def self_changed?
>> +      changed_nodes.keys.include?(ENV["SERF_SELF_NAME"])
>> +    end
> 
> changed_nodesってHashですよね?であれば、
> 
>   changed_nodes.key?(ENV["SERF_SELF_NAME"])
> 
> でいいですよ。
> 
> http://rurema.clear-code.com/2.1.0/method/Hash/i/has_key=3f.html
> 
> keys.include?だとキーの配列を作ってから比較しますが、key?だ
> と配列を作らずにチェックするので、必要のないオブジェクトが登
> 場しなくなり、コードがスッキリすると思います。
> 
> In <f9114cc6fd70ae7fe55083981d927961583cef75 �� jenkins.clear-code.com>
>   "[Groonga-commit] droonga/droonga-engine �� f9114cc [master] Discard old live nodes list" on Thu, 08 May 2014 17:19:52 +0900,
>   YUKI Hiroshi <null+groonga �� clear-code.com> wrote:
> 
>> YUKI Hiroshi	2014-05-08 17:19:52 +0900 (Thu, 08 May 2014)
>>
>>   New Revision: f9114cc6fd70ae7fe55083981d927961583cef75
>>   https://github.com/droonga/droonga-engine/commit/f9114cc6fd70ae7fe55083981d927961583cef75
>>
>>   Message:
>>     Discard old live nodes list
>>
>>   Modified files:
>>     lib/droonga/serf_event_handler.rb
>>
>>   Modified: lib/droonga/serf_event_handler.rb (+10 -0)
>> ===================================================================
>> --- lib/droonga/serf_event_handler.rb    2014-05-08 17:03:22 +0900 (698d49a)
>> +++ lib/droonga/serf_event_handler.rb    2014-05-08 17:19:52 +0900 (ea9ab63)
>> @@ -57,7 +57,15 @@ module Droonga
>>        @payload = $stdin
>>      end
>>  
>> +    def self_changed?
>> +      changed_nodes.keys.include?(ENV["SERF_SELF_NAME"])
>> +    end
>> +
>>      def changed_nodes
>> +      @changed_nodes ||= parse_changed_nodes
>> +    end
>> +
>> +    def parse_changed_nodes
>>        nodes = {}
>>        @payload.each_line do |node|
>>          name, address, role, tags = node.strip.split(/\s+/)
>> @@ -71,6 +79,8 @@ module Droonga
>>      end
>>  
>>      def last_live_nodes
>> +      return {} if self_changed?
>> +
>>        return {} unless @live_nodes_file
>>        return {} unless @live_nodes_file.exist?
>>  
> 
> _______________________________________________
> Groonga-commit mailing list
> Groonga-commit �� lists.sourceforge.jp
> http://lists.sourceforge.jp/mailman/listinfo/groonga-commit
> 

-- 
結城 洋志 <YUKI Hiroshi>
E-mail: yuki �� clear-code.com

株式会社クリアコード
〒113-0033 東京都文京区本郷3-27-12
           本郷デントビル2階
TEL : 03-6231-7270
FAX : 03-6231-7271
WWW : http://www.clear-code.com/




More information about the Groonga-commit mailing list
Back to archive index