-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, Hugh Sasse wrote: > For a database application I found using CSV to be rather slow. > I have made an attempt to speed it up, which, frankly has not been > very successuful. However I think I have improved the code a > little. Thanks. > I've added an error for if the state machine should get into an > unknown state, rather than assuming that "it must be in the other > one" after several tests. This slows things down, but is probably > safer, given how hard state machines can be to debug. > > I've changed if block to if block_given? -- more idiomatic, Indeed. > possibly faster?? Have you tried profiling it? > I've tried to simplify > if something.is_a?(Klass) > something.method > end > to > if something.respond_to?(:method) > something.method > end I expect Fixnum here, not 'chr'-able... > I've changed > if expr > singlestatement > end > > to > singlestatement if expr > > to shorten the code. Don't know how that impacts speed. if expr singlestatement end style is intended for measuring test coverage. > I have tested the code and it still works. I could not find > exhaustive test cases for CSV (looked in Rubycon and on the web) so > hope I haven't broken anything. Please find the bundled test from test/csv/test_csv.rb. It covers almost all lines so it should help you to refactor csv.rb Regards, // NaHi -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) iD4DBQFDYj0Zf6b33ts2dPkRAhnsAJY9h+OsEiQXlo6y+yTbVQm1dsCFAJ4wgCcn 9hYhduEv84V6PtHQEsvnAg== =EbYf -----END PGP SIGNATURE-----