"Paul A. Rombouts" <[EMAIL PROTECTED]> writes:

> "Andrew M. Bishop" wrote:
> > 
> > When I code I use the principle of Keeping It Simple.  This doesn't
> > always mean that the shortest and fastest piece of code is always the
> > best.  There are times that taking a black box approach will win even
> > though the code is longer and slower.  If you need to change every
> > place where the wildcard pattern is used then perhaps it is not simple
> > enough.
> 
> Yes, I appreciate your KISS coding style. I'm not quite sure what you mean by a
> "black box approach", though.

I think that the best way to explain it is that you can keep things
simple by only optimising the code within a function.  Wherever you
try and optimise the code for a function globally (between the
function and the one that calls it) then you add complications and
dependencies.  The function that you optimise is the "black box" the
caller of the function needs not know how it works or try to optimise
for how it works.

In this case the WildcardMatch() function takes two arguments, a
string containing some *s and a string that you are trying to match
with it.  No other function needs to know how it works and you don't
need to change the code in lots of places to make it work.

> Nevertheless, I think the wildcard pattern matching function can be improved.

>From looking at your code I think that it is possible to match more
than two *s with your algorithm and with my black box approach at no
extra run-time cost.  We don't need to debate the finer details on
this mailing list unless you particularly want to; I wouldn't want to
lose too many subscribers :-)


> I've also made some optimizations by taking the "SplitHostPort" and
> "RejoinHostPort" operations outside of loops. Because I have I a rather long
> DonGet section, I felt it was worthwhile.

This is probably worthwhile, but the MatchUrlSpecification() function
becomes less of a black box since you need to optimise the code around
it in several places.  You could remove 90% of the SplitHostPort()
function calls by placing the host and port separately in the Url
structure anyway if you wanted to go that route.  They are split up
that way when the URL is first parsed from a string.



> > Does the patch work with version 2.7-beta?  There has been a lot of
> > change of the configuration file reading, especially the UrlSpec data
> > type.
> 
> I haven't got around to studying the 2.7-beta code in detail yet. But I see no
> reason why the changes I've made to the 2.6d version can't be carried over to
> version 2.7.

The main problem would be the massive re-arrangement of the code in
the config.[ch] files (which is now 4 *.c files and 2 *.h files).


> I'm only beginning to study the 2.7-beta code, but I will start merging the
> changes I've made to the 2.6d code into the 2.7-beta code soon. But I'm still a
> bit apprehensive about actually running beta code. (Sorry).

Perhaps calling it beta version makes people think that it is worse
than it is.  So far there have been no major problems with it (just to
encourage anybody else to have a look before the final release).

-- 
Andrew.
----------------------------------------------------------------------
Andrew M. Bishop                             [EMAIL PROTECTED]
                                      http://www.gedanken.demon.co.uk/

WWWOFFLE users page:
        http://www.gedanken.demon.co.uk/wwwoffle/version-2.6/user.html

Reply via email to