Skip to content

VS2010 Compilation errors and Equality/HashCode fixes#7

Open
CodesInChaos wants to merge 2 commits into
mhutch:mainfrom
CodesInChaos:master
Open

VS2010 Compilation errors and Equality/HashCode fixes#7
CodesInChaos wants to merge 2 commits into
mhutch:mainfrom
CodesInChaos:master

Conversation

@CodesInChaos

Copy link
Copy Markdown

When compiling Quaternion.cs with VS2010 I get an error because the out parameter is not definitely assigned. This is because you only assign properties. I've added result = new Quaternion() where necessary.
I've added code fixing the quality problems in safe mode for Vector2, Vector3, Vector4 and Quaternion and added a unit tests to verify if equality behaves as expected.

@mhutch

mhutch commented Jun 22, 2011

Copy link
Copy Markdown
Owner

The arg-less ctor will result in setting all fields to zero, so there will actually be 6 assignments. While a good optimizing compiler should be able to inline and eliminate it, I'm pretty sure neither .NET or Mono's JIT will do that. A better solution would be to make the fields internal and set them directly, like I did on the Vector classes.

@mhutch

mhutch commented Jun 22, 2011

Copy link
Copy Markdown
Owner

Though in practice it might just allocate everything from zeroed memory and thus be able to completely eliminate the blank ctor, AFAIK that isn't guaranteed.

@CodesInChaos

Copy link
Copy Markdown
Author

You could also simply call the constructor that takes parameters. What I did was the smallest change to actually make it compile.

@CodesInChaos

Copy link
Copy Markdown
Author

I've added code fixing the quality problems in safe mode for Vector2, Vector3, Vector4 and Quaternion and added a unit tests to verify if equality behaves as expected.

I assume the SIMD mode will fail these tests, but since I don't use mono I can't verify/fix it.

Base automatically changed from master to main March 4, 2021 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants