Jump to content

New code style for mangos


Guest ChaosBUG
 Share

Recommended Posts

Mangos need some special coding and optimize.

In all cycles:

if ( 0 = var )

better then

if ( var = 0 ).

Compiler can check this while compilation, and point this errors.

Many functions can't return from wrong arguments, like:

Player* player = 0;

- always crash server. I can do this in some places.

We have many wrong places in code now. We need new crashcheck policies in framework.

Link to comment
Share on other sites

0 = var

works? - or better question: what should this do? and why compiler should notice something there..

Player* player = 0;

what are you doing there?

and also for pointers using NULL is good codestyle..

in general i don't realy know what you want

Same here, more on that "a = 0" and "0 = a" -- it's like ++i versus i++ with typo protection instead of speed boost.

Ie. if you make a typo and write (a = 0) instead of (a == 0), it will zero the variable (in some languages), which can lead to hidden bugs. On the other hand, a (0 = a) typo (instead of (0 == a)) would generate a compiler error.

IMHO it isn't that useful here to be worth using (and rewriting current implementation), ...

Link to comment
Share on other sites

I already do this in most of my code, read about it a while ago, and it's a great way to prevent incidental assignments.

// Current code accidental assignment
if(a = 0) {} // No error, variable gets assigned a value of 0

// With the changes
if(0 = a) {} // Compile error because the operation is impossible

Link to comment
Share on other sites

I do not understand last post.

I am OOP programmer. I can profile mangos code with Intel VTune and i do it every build. I translate C++ commands to assebler commands and convert it back to C++.

Some functions in mangos use conversions uint32 yo uint64 and back, but compiler can say warning on it and no more. But during server works this conversion take more time.

And this examples more, more and more...

I want maximum efficiency from mangos code with minimum timing, but now it's impossible.

Link to comment
Share on other sites

To be frank, I do not think this is the time to go worry about micro-optimalisations. There are areas that can give far greater performance increase (like using prepared statements for example, or making the worldserver multithreaded) than using these very small improvements.

If the core was bugfree, stable and all other means of optimizing had been exhausted, yes, but as it stands I prefer the developers to focus on other issues. Though of course I look forward to seeing patches from you on this matter, I am sure they will be accepted if they help.

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use