]> git.cworth.org Git - sup/blobdiff - lib/sup/mbox/loader.rb
maintain labels as Sets rather than arrays
[sup] / lib / sup / mbox / loader.rb
index ea277cf0f80ffa41397484a92a6940cb468dd0a2..f35c7df8f37b489fb38ebb8827e2d9e50a1985de 100644 (file)
@@ -1,17 +1,17 @@
 require 'rmail'
 require 'uri'
+require 'set'
 
 module Redwood
 module MBox
 
 class Loader < Source
   yaml_properties :uri, :cur_offset, :usual, :archived, :id, :labels
-  attr_accessor :labels
 
   ## uri_or_fp is horrific. need to refactor.
-  def initialize uri_or_fp, start_offset=0, usual=true, archived=false, id=nil, labels=[]
+  def initialize uri_or_fp, start_offset=0, usual=true, archived=false, id=nil, labels=nil
     @mutex = Mutex.new
-    @labels = ((labels || []) - LabelManager::RESERVED_LABELS).uniq.freeze
+    @labels = Set.new((labels || []) - LabelManager::RESERVED_LABELS)
 
     case uri_or_fp
     when String
@@ -168,7 +168,7 @@ class Loader < Source
     end
 
     self.cur_offset = next_offset
-    [returned_offset, (self.labels + [:unread]).uniq]
+    [returned_offset, (@labels + [:unread])]
   end
 end