Is there a reason why quick_add_integer_constant takes a char* and a length, instead of a (much quicker and cleaner) struct pike_string* which would enable it to work more efficiently in collaboration with MK_STRING() ?
I see that the functions do not seem to be used anywhere, so I propose to change the (internal) interface definition for them to actually make them quick.
quick_add_integer_constant() is not internal, it is marked PMOD_EXPORT so it may be used by external modules.
Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum wrote:
quick_add_integer_constant() is not internal, it is marked PMOD_EXPORT so it may be used by external modules.
Yes, well, granted. Is it actually being used somewhere?
There's no way of knowing. Please don't change the API of exported functions. If you feel the need for a function with a different API, please call it something else.
Is there a reason why quick_add_integer_constant takes a char* and a length, instead of a (much quicker and cleaner) struct pike_string* which would enable it to work more efficiently in collaboration with MK_STRING() ?
The quick* functions in program.c are typically called via the corresponding ADD_*() macros (in this case ADD_INT_CONSTANT()). The "quick" in the name has mostly to do with the string-lengths being calculated statically, and probably ought to have been "simple", since the functions are intended to be easy to use from C-code.
If you already have a struct pike_string, you would probably want to call add_constant() directly rather than {quick_,}add_integer_constant().
I see that the functions do not seem to be used anywhere, so I propose to change the (internal) interface definition for them to actually make them quick.
It seems you missed that it is used by the ADD_INT_CONSTANT() macro, there's quite a few uses of ADD_INT_CONSTANT() in eg builtin_functions.c and modules/system/*.c.
Henrik Grubbstr?m (Lysator) @ Pike (-) developers forum wrote:
Is there a reason why quick_add_integer_constant takes a char* and a length, instead of a (much quicker and cleaner) struct pike_string* which would enable it to work more efficiently in collaboration with MK_STRING() ?
The quick* functions in program.c are typically called via the corresponding ADD_*() macros (in this case ADD_INT_CONSTANT()). The "quick" in the name has mostly to do with the string-lengths being calculated statically, and probably ought to have been "simple", since the functions are intended to be easy to use from C-code.
Yes, well, figured that out, eventually; however, these are all one-time calls, for fairly short strings as identifiers. I'm having a hard time justifying why someone insisted on creating the quick_ versions just to be able to use make_shared_binary_string instead of make_shared_string. It will save one pass over the string to find the trailing \0, yes, but since it's all initialisation, and the string in most cases fits in the cache (and this is true now, and would have been equally true 20 years ago), there is close to no speed benefit.
If you already have a struct pike_string, you would probably want to call add_constant() directly rather than {quick_,}add_integer_constant().
Well, I have a proposed cleanup which keeps the current binary interface intact.
pike-devel@lists.lysator.liu.se