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

Default parameters #12

Open
kkaefer opened this issue Jul 14, 2017 · 4 comments
Open

Default parameters #12

kkaefer opened this issue Jul 14, 2017 · 4 comments
Labels

Comments

@kkaefer
Copy link
Member

kkaefer commented Jul 14, 2017

I'm wondering why the parameters for Bin are set to default to -1, in particular for x and y. Would a better default be 0?

/cc @bhousel

@kkaefer
Copy link
Member Author

kkaefer commented Jul 14, 2017

Background is that not setting them to 0 explicitly triggers undefined behavior when dividing by the offset (mapbox/mapbox-gl-native#9509)

@bhousel
Copy link
Contributor

bhousel commented Jul 14, 2017

I think I just used -1 as uninitialized because 0,0 is a real coordinate that a bin can be packed into.

@kkaefer
Copy link
Member Author

kkaefer commented Jul 14, 2017

Okay; are there any use cases for initializing a Bin object without setting its location? If not, I think the parameters shouldn't be optional.

@bhousel
Copy link
Contributor

bhousel commented Jul 14, 2017

Bins start out with no location until they are packed. So, external code should never supply a location.
see https://github.com/mapbox/shelf-pack-cpp#batch-packing

Only the internal shelf.alloc method should create bins with a location, see here

I'm not sure the most idiomatic (and performant) C++ way to implement this. It would be great to drop the x and y arguments from the Bin constructor, in order to clear up the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants