The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Speeding Up Builder 2.0

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Speeding Up Builder 2.0 Posted: Jun 19, 2006 3:31 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Speeding Up Builder 2.0
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

This week I’m trying to break the skids off of Markaby. A recent Camping audit has lit up Markaby as the slowpoke. And I happened to root up a bit of slowness in Builder::XChar. The Range.include? is killing us because the Range gets cast to an Array every time!

My friends, in your lives, in your valuable time, do not, in any case, use Range#include? Use Range#===. (0x0000..0xFFFF) === 0xBABE you know it’s true. I have been careless, too.

Here’s a replacement:

 module XChar
 VALID = [
 0x9, 0xA, 0xD,
 (0x20..0xD7FF),
 (0xE000..0xFFFD),
 (0x10000..0x10FFFF)
 ]
 end
 class Fixnum
 # XML escaped version of chr
 def xchr
 n = XChar::CP1252[self] || self
 case n when *XChar::VALID
 XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};")
 else
 '*'
 end
 end
 end

Which gave me a 30% speed up on the tests Atrus was running. The UTF-8 unpack is also taking some time. I wonder.

Read: Speeding Up Builder 2.0

Topic: Ruby snippet: detaching a method from an object as a closure Previous Topic   Next Topic Topic: Stack de llamadas en Java :: desde HTTP hasta JDBC

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use