Permalink
Browse files

reuse one encoder instance, with a newline termination character set

  • Loading branch information...
1 parent dc866ba commit fe794bec2cb55b0cafbb2c7d4a5fa35722b41c32 @brianmario brianmario committed Apr 4, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/talker/client.rb
@@ -46,7 +46,7 @@ def users
end
def send(data)
- send_data Yajl::Encoder.encode(data) + "\n"
+ send_data @encoder.encode(data)
end
def send_message(message, attributes={})
@@ -86,6 +86,8 @@ def connection_completed
def post_init
@parser = Yajl::Parser.new
@parser.on_parse_complete = method(:event_parsed)
+
+ @encoder = Yajl::Encoder.new(:terminator => "\n")
end
def receive_data(data)

0 comments on commit fe794be

Please sign in to comment.