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

Replace several bool values in ProbabilityState with a single uint8_t status to save space. #44

Open
ifndefJOSH opened this issue May 4, 2023 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers optimization

Comments

@ifndefJOSH
Copy link
Collaborator

Currently there are a bunch of boolean values in the ProbabilityState class which could be condensed into something smaller:

class ProbabilityState {
public:
...
	bool assignedInRemapping;
	bool isNew;
	bool wasPutInTerminalQueue;
	bool preTerminated;
	bool deadlock;
...
// More code here
}

We could use a single uint8_t status to hold all of these values, with bit 0 being assignedInRemapping, bit 1 being isNew, etc... and use bitwise math to get the values like so:

// Somewhere Above
const uint8_t ASSIGNED_IN_REMAPPING_INDEX = 0;
const uint8_t IS_NEW_INDEX = 1;
...
void 
ProbabilityState::setAssignedInRemapping(bool value) {
    // Create bitmask and zero out the desired bit
    status &= ~(0x1 << ASSIGNED_IN_REMAPPING_INDEX);
    // Set the desired bit to the desired value
    status |= (uint8_t) value << ASSIGNED_IN_REMAPPING_INDEX;
}
bool
ProbabilityState::wasAssignedInRemapping() {
    return (status >> ASSIGNED_IN_REMAPPING_INDEX) & 0x1;
}

If anyone wants to help out on this, I think this would be a good first issue for a newcomer.

@ifndefJOSH ifndefJOSH added enhancement New feature or request optimization good first issue Good for newcomers labels May 4, 2023
@shivamganwani
Copy link

assignedInRemapping where is this being used? I don't see anyone getting it.
Can you please help with this confusion @ifndefJOSH

@ifndefJOSH
Copy link
Collaborator Author

@shivamganwani Thank you for taking an interest in my project! Please look at the dev branch. (git checkout dev)

@shivamganwani
Copy link

@ifndefJOSH this project won't run on windows right. As my Virtual box has some issue, I wont be able to work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers optimization
Projects
None yet
Development

No branches or pull requests

2 participants