Re: [pcre-dev] pcre_compile.c: error_texts

Startseite
Nachricht löschen
Autor: Philip Hazel
Datum:  
To: Zoltán Herczeg
CC: pcre-dev
Betreff: Re: [pcre-dev] pcre_compile.c: error_texts
On Mon, 31 Dec 2012, Zoltán Herczeg wrote:

> Alternatively, we can simply use something like:
> static char* error_texts[] = { "text1", "text2", ... };
> error_texts[i] would return with the text corresponding to error code.


Isn't that what we are trying to avoid? I suspect that is what it used
to be before the relocation issue was raised. This is the ChangeLog
entry for release 7.4:

10. It was pointed out to me that arrays of string pointers cause lots of  
    relocations when a shared library is dynamically loaded. A technique of 
    using a single long string with a table of offsets can drastically reduce
    these. I have refactored PCRE in four places to do this. The result is 
    dramatic:                                                   


      Originally:                          290                            
      After changing UCP table:            187
      After changing error message table:   43                                 
      After changing table of "verbs"       36                                
      After changing table of Posix names   22                              


    Thanks to the folks working on Gregex for glib for this insight.      


My own view about this is that I don't think any gain is worth the
effort of making any change. After all, we hope that most of the time
there are no compilation errors, so it doesn't really matter how long it
takes to find an error message.

On Sun, 30 Dec 2012, Kevin Connor Arpe wrote:

> What if we create a (static) list of offsets that is only initialised at
> first compile error?


Since pcre_compile() gives up on hitting a compile error, there are only
ever "first" compile errors, so I'm not quite sure what the propsed gain
is here.

Thanks for taking the time to get involved and to raise this issue. It
is always good to know that people are scrutinizing the code and
worrying about how it works. Only yesterday I applied a patch to change

pcre_uchar op;    (which is unsigned char op)


into

unsigned int op;

because another user had noticed that this made a noticeable performance
improvement in his Windows environment.

As for cathedrals and bazaars, until a couple of years ago I was the
only maintainer, though over time plenty of people had sent in
suggestions, patches, etc. which I scrutinized and usually adopted in
some form or other. Nowadays Zoltán and Christian Persch have joined me
in a small "team". It's all quite informal.

Philip

--
Philip Hazel