From 31e93e54f93da8a932f8aad328245eae09279be4 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Sat, 21 Mar 2015 01:27:00 +0100 Subject: [PATCH] Removed Mutex usage from XML::Text Instead of trying to make this class thread-safe I'm going with the option of simply declaring it unsafe to mutate instances of XML::Text while reading it in parallel. This removes the need for Mutex allocations and keeps the code simple. Fixes #82 --- lib/oga/xml/text.rb | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/oga/xml/text.rb b/lib/oga/xml/text.rb index edb585a..22ac02b 100644 --- a/lib/oga/xml/text.rb +++ b/lib/oga/xml/text.rb @@ -8,7 +8,6 @@ module Oga def initialize(*args) super - @mutex = Mutex.new @decoded = false end @@ -16,11 +15,8 @@ module Oga # @param [String] value # def text=(value) - # In case of concurrent text/text= calls. - @mutex.synchronize do - @decoded = false - @text = value - end + @decoded = false + @text = value end ## @@ -30,12 +26,10 @@ module Oga # @return [String] # def text - @mutex.synchronize do - unless @decoded - decoder = html? ? HTML::Entities : Entities - @text = decoder.decode(@text) - @decoded = true - end + unless @decoded + decoder = html? ? HTML::Entities : Entities + @text = decoder.decode(@text) + @decoded = true end return @text