Which one do you prefer to use?
First code
100.00%
2
Second code
0%
0
2 vote(s)
* You voted for this item. [Show Results]

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Optimization in pawno.
#5
CMIIW: The only thing a `new` usually does is, initialize a variable. You don't allocate any variables at runtime, because PAWN is a statically compiled language - there are no runtime allocations*.

While the second example might theoretically be faster.. instead of thinking about micro- and premature optimization, think about code readability (magic numbers, variable names, function names, layout of the code, indentation, verbosity), design (apply programming patterns that suit the use case, manage responsibilities, don't make spaghetti-intertwined dependencies, dependency loops, logical units/modules, etc), profiling real bottlenecks and future maintainability (would you, or someone else, still understand what your code does 6 months from now, 2 years from now, 10 years?).

* - Unless some functions offer that, e.g. via plugins.
  Reply


Messages In This Thread
Optimization in pawno. - by AsteriskRin - 2020-12-03, 04:34 AM
RE: Optimization in pawno. - by Awide - 2020-12-03, 04:31 PM
RE: Optimization in pawno. - by Pinch - 2020-12-03, 06:12 PM
RE: Optimization in pawno. - by Kwarde - 2020-12-04, 07:56 PM
RE: Optimization in pawno. - by gzxmx94 - 2020-12-07, 10:12 AM

Forum Jump: