Issue #7065 has been updated by Eregon (Benoit Daloze).


luislavena (Luis Lavena) wrote:
> How about moving ansi regexp as constant so regexp object doesn't get allocated on every formatter.call?

If I'm not mistaken this is unnecessary, as "static" (without #{...}) Regexps are created only once (because they are immutable):

    class Formatter
      def clean
        /\e\[[0-9;]*m/
      end
  
      def clean2
        />#{'a'*2}</
      end
    end

    2.times { p Formatter.new.clean.object_id }
    puts
    2.times { p Formatter.new.clean2.object_id }


----------------------------------------
Bug #7065: Syslog::Logger should have a formatter
https://bugs.ruby-lang.org/issues/7065#change-29748

Author: tenderlovemaking (Aaron Patterson)
Status: Open
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: 
Target version: 
ruby -v: ruby 2.0.0dev (2012-09-24 trunk 37026) [x86_64-darwin12.2.0]


Hi, Syslog::Logger should have a formatter so that it can behave similar to the regular Logger class.  I've attached a patch with tests to implement the formatter.

Thanks!


-- 
http://bugs.ruby-lang.org/