Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
On Wed, May 19, 2010 at 5:15 PM, pancake wrote: > i dont see the point of having: > char *moo(){ >  char *foo; >  foo = strdup("bar"); >  return foo; > } > > when you can have: > > char *moo() { >  return strdup ("bar"); > } Tail recursion indeed looks elegant, but doesn't check for NULL, so you

Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
On 05/19/2010 04:47 PM, Troels Henriksen wrote: Elmo Todurov writes: * less mallocs, less copying strings around (no noticeable change in I really think this MAX_PATH thing is a bad idea. You can argue that a system with paths that deep is broken, but I think a suckless program should be

Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
Okay, here's the new version. Changes: * no root check * -f instead of --force * less mallocs, less copying strings around (no noticeable change in speed, though) * die() Elmo Todurov /* * dmenu_path * This program dumps all executables in $PATH to stdout. * It uses the file

Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
On 05/19/2010 04:23 PM, Connor Lane Smith wrote: On 19/05/2010, Elmo Todurov wrote: 7) I would change --force flag check to be just '-f' 8) why do you check for root? Why do you use dmenu_path as root? I can't see any use cases for this. "UNIX was not designed to stop

Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
On 05/19/2010 02:24 PM, pancake wrote: 1) In unix there's a MAXPATH variable.. in fact GNU does not have this limit, but in unix is 4096 and in plan9 256 (afaik) Actually, PATH_MAX. the thing is that keeping a clean system you shouldn't have paths that big. agreed So you can define a sing

Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
On 05/19/2010 03:23 PM, Connor Lane Smith wrote: I find it extremely confusing to read - but maybe I'm just not used to the style. Well, that's the style I'm used to. I tried to find the style guidelines, but the only thing I found is http://suckless.org/devel/style_guide which is pretty thor

Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
On 05/19/2010 02:40 PM, Anselm R Garbe wrote: On 19 May 2010 12:24, pancake wrote: 10) put ".dmenu_cache" path as define on top of C file. so you can change it easily. Nah, change the semantic slightly and pass the cache path in as argument instead. Actually, originally I did this, but then

Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
On 05/19/2010 01:32 PM, pancake wrote: i would probably even improve the heap usage of this .c, but it's better solution than the shellscript one IMHO. How? Elmo Todurov

Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
topic. Elmo Todurov

Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
think I've ever tried parallelising a shell script. Sounds plausible. I'll try it when I get time. Elmo Todurov

Re: [dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
On 05/19/2010 12:42 PM, Anselm R Garbe wrote: I think the existing shell script based dmenu caching is already quite fast (assumed the cache exists) The reason I wrote this is occasional lag when executing dmenu. I'm not sure I've fixed the problem, though (= Consider it an exercise in practi

[dev] dmenu_path rewrite in C

2010-05-19 Thread Elmo Todurov
Hi there. I rewrote dmenu_path in C. It's an order of magnitude faster than the shell script on cache misses and around 2 times faster on cache hits. I'm attaching the code to this mail. I'd be glad to see it included in dmenu. Elmo Todurov /* * dmenu_path * This pr