Re: try find the fastest way to convert a group string into index?

2018-09-16 Thread learnfirst1 via Digitalmars-d-learn
On Sunday, 16 September 2018 at 11:51:24 UTC, learnfirst1 wrote: On Sunday, 16 September 2018 at 11:30:11 UTC, learnfirst1 wrote: On Sunday, 16 September 2018 at 10:14:24 UTC, Vladimir Panteleev wrote: I will test pcre solution vs mpfc for benchmark. the pcre is easy to deal with low/up

Re: try find the fastest way to convert a group string into index?

2018-09-16 Thread learnfirst1 via Digitalmars-d-learn
On Sunday, 16 September 2018 at 11:30:11 UTC, learnfirst1 wrote: On Sunday, 16 September 2018 at 10:14:24 UTC, Vladimir Panteleev wrote: It has to be case Case Insensitive, so before I run mpfh for each new request headers, I need to convert the keys into low or up case. this value can be

Re: try find the fastest way to convert a group string into index?

2018-09-16 Thread learnfirst1 via Digitalmars-d-learn
On Sunday, 16 September 2018 at 10:14:24 UTC, Vladimir Panteleev wrote: On Sunday, 16 September 2018 at 10:04:09 UTC, learnfirst1 wrote: how to make this more fast like with one loop and get the results. thanks for reply, minimal perfect hashing seems good for this task, I will do more test

Re: try find the fastest way to convert a group string into index?

2018-09-16 Thread Diederik de Groot via Digitalmars-d-learn
Homework ? I think it would also be better to only walk/match the Header.data and header_keys only once (using the generated switch statement that Vladimir suggested). So your Headers struct should have a parse() function, which will match all of the headers to the keys and store them

Re: try find the fastest way to convert a group string into index?

2018-09-16 Thread Vladimir Panteleev via Digitalmars-d-learn
On Sunday, 16 September 2018 at 10:04:09 UTC, learnfirst1 wrote: how to make this more fast like with one loop and get the results. This is a more general problem than any specific programming language; you may want to look into perfect hashing:

try find the fastest way to convert a group string into index?

2018-09-16 Thread learnfirst1 via Digitalmars-d-learn
The use case is translate http header key into enum. this is the current code : https://run.dlang.io/is/lpw29w In this fake code I only list a few headers, it should be more. but less then 128 and only include the a few codes. how to make this more fast like with one loop and get the