Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Tom Copeland
RE: Code cleanup [ reply ]  
2004-09-03 14:22
Very nice! Much more efficient, I'm sure...

Yours,

Tom

By: Ikkei
RE: Code cleanup [ reply ]  
2004-09-03 03:15
> but a daemon would be much more efficient.

Oh, WEBrick can help to make the http based daemon.
I put sample code in my tar ball at (./sample/bt-tracker.rb)

By: Tom Copeland
RE: Code cleanup [ reply ]  
2004-08-31 20:26
> ?0..?9

Good point, even better.

> Trakcer's bee encoder better be
> optimize, because of tracker may
> recieve a lot requests.

Ah, very true - since every HTTP response is bencoded. Hm. My current work on the tracker is running it as a CGI script... but a daemon would be much more efficient. Shouldn't be hard to switch back and forth, though, just a little front end work...

Yours,

Tom

By: Ikkei
RE: Code cleanup [ reply ]  
2004-08-31 19:48
Hello,

Generally, normal recursive way may be slower
but it's more easy to read/write the code.

Now I plan to change it to

< '0'..'9'
> ?0..?9

Because of It is a char.


NOTES: Before local optimize. where should optimize

Download client's bee decoder/encoder does not need optimize. its not called so much time, unless download many files.

Trakcer's bee encoder better be optimize,
because of tracker may recieve a lot requests.

By: Tom Copeland
RE: Code cleanup [ reply ]  
2004-08-31 17:45
Hi Ikkei -

Thanks, very interesting! I like your use of the case statement; I should do some benchmarks to see if it's faster to do a:

=~ /[0-9]

or a:

'0'..'9'

I suspect your way is faster...

Yours,

Tom

By: Ikkei
RE: Code cleanup [ reply ]  
2004-08-31 14:04
> bencoder code
My approach was use stringio and recursive call.
but a bit slower ...

http://www1.kcn.ne.jp/~tea/tmp/rubit/
(Here, I uploaded for temporaly)

By: Tom Copeland
Code cleanup [ reply ]  
2004-08-30 16:08
- the bencoder code isn't very nice; seems like it should use a Tokenizer/Context/Parser rather than the current clutter
- the decoder has some duplicate code
- is there a better way to use optparse?

Onwards and upwards,

Tom