Skip to content
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

unnecessary compassion in b2_collision.cpp #748

Open
kritma opened this issue Jun 10, 2023 · 3 comments
Open

unnecessary compassion in b2_collision.cpp #748

kritma opened this issue Jun 10, 2023 · 3 comments

Comments

@kritma
Copy link

kritma commented Jun 10, 2023

	if (count < 3 || count > b2_maxPolygonVertices)
	{
		// check your data
		return hull;
	}

	count = b2Min(count, b2_maxPolygonVertices); //this line is unnecessary
@krabhi1
Copy link

krabhi1 commented Oct 6, 2023

How?

@HughPH
Copy link

HughPH commented Oct 6, 2023

count must always be less than or equal to b2_maxPolygonVertices according to the preceding if statement, so the call to b2Min is not required.

@kritma
Copy link
Author

kritma commented Oct 6, 2023

@krabhi7
this is same as

if(count < 3) {
    return hull;
}

if(count > b2_maxPolygonVertices) {
    return hull;
}

count = b2Min(count, b2_maxPolygonVertices); // count <= b2_maxPolygonVertices because of early return

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

No branches or pull requests

3 participants