-
Notifications
You must be signed in to change notification settings - Fork 589
Convert several UTF-8 related functions into macros #23459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: blead
Are you sure you want to change the base?
Conversation
do they? One serious problem with macros (and more macros and more macros) is they have global scope, and I don't mean top-level scope - I mean they replace anywhere. I know the existing macros break C++ headers, I've had to work around this by making sure I include the perl headers after anything else when writing XS. (names like "seed" and "Copy" don't help)
|
The function is hereby removed in favor of calling the plain uvoffuni_to_utf8_flags macro that already exists
These were inline functions, but macros require fewer resources; I intented them to be macros all along, but until 93f23f0, that was harder.
This was an inline function that just called another function; a macro uses fewer resources
d815115
to
24a3ecc
Compare
In the case of this p.r., there is less runtime overhead, and the names are very unlikely to conflict with others. But what we could do is change handy.h to
And change embed.h so it looks more like
When you compiled your code using plain The long name calls would have to include aTHX_ when appropriate. I believe I know how to fix regen/embed.pl to automatically DTRT for thread context; it would use the new scheme only if the macro name begins with This requies extra work, and would be impractical if a significant number of our short names have conflicts. |
evidence? Testing this change vs blead, the exact same code was generated for the call to uv_to_utf8() in If you think this will improve runtime overhead in some other specific case, let me know and I'll take a look.
I agree in this case.
I think the ship has sailed here. My point is that macros are pretty bad, claiming they're better than an inline function where an inline function works needs some evidence. |
I think I see part of the disconnect. I can see that the inline functions would not require more resources than macros. And I converted them to inline at the last minute in 5.41, as a result of having to revert some commits. This was intended to be a temporary measure. But they work well enough there, so we could leave them. I also am still influenced by the times when inlined functions were a precious resource because compilers had a very finite limit on how many you could have. Making them inline functions adds more boiler plate to the code base. The other function is in utf8.c, and merely implements the long form of uvoffuni_to_utf8_flags, Calling the long form adds an indirection. By changing the flag on an embed.fnc entry, that code in utf8.c can be removed |
These functions are all essentially one-liners that just call something else. Now that 93f23f0 is in blead, it is easy to convert them to macros that don't have extra overhead