-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
Convert constants to values at compile time #222
Comments
It does not seem to me that it is measurably faster. |
It is secondary litle reason, i try 10k cycle where is cca 4x faster.
First idea was: Is posible in compile time use raw value insteand of Statement for constant? |
It can be done, but it's a BC break. Because someone can rely on the current way. |
It's probably slower because function call is used. So what if we instead of |
I need value of constant in compile time. This |
What about keep Statement and add new property with value? Is not ideal, because is only for ::constant. What about new class StatementConstant extend Statement and ovewrite behavior? This couldn't be BC break? |
One point If you use direct constant like describe @mabar, that is safer if value changed. Because if set raw value and change constant. In this moment nette does not rebuild container. |
In this moment if you write constant to neon like this
class
In compile time I get Statement object
In my use case I need value of constant, here is not problem do it.
I convert constant to value in compile time like this:
If I thinking about it, the constants can be convertet to value by nette in compile time everytime.
If i made benchmark of this solution that is faster, because it has raw value instead of call function constant with parameter string like this
'languageId' => constant('MyLanguageEnum::CZECH')
. The goal is'languageId' => 1
.What do you think?
The text was updated successfully, but these errors were encountered: