From: Brian H. <bri...@ql...> - 2003-05-22 17:58:16
|
On Thu, 22 May 2003, Michal Moskal wrote: > > Sanity check this code, if you will: > > > > if i >= (m - 1) then next > ^^^^^^^ > > I'm not quite sure how good is ocamlc wrt moving constants out of loop, > but probably moving this substraction out of the loop would be The Right > Thing. For a simple decrement I wouldn't worry too much about strength reduction. At worst it's a single clock cycle cost- i.e. too low to notice generally. > > And it gets rid of all the references- > > which probably means a speed up (haven't tested it yet though). > > Maybe refs are optimized away by the compiler? But I don't know. I don't know either. > > > Although > > one thing we might want to consider: actually exporting the kmp_init > > function and kmp function seperately. This way if I wanted to find the > > same substring in a lot of different strings, I don't have to constantly > > recreate the next table. Maybe something like: > [snip] > > I think better as submodule: Yes. Can we do modules in modules? I.e.: String.KMP.compile and String.KMP.match, like: let pat = String.KMP.compile p in String.find_all (fun s -> try let _ = String.KMP.match pat s in true with Not_found -> false) strlist Brian |