We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Possible improvement for jump function. Limits: x,y max values 0-32767 (0x7FFF)
How about instead of allocating memory every time you jump: int *Jump(...) { return int *i = (int *) malloc(2 * sizeof(int)); }
you could replace it with bit operations, and return int number instead (NULL will be equal to -1):
int Jump(...) { if(!IsWalkableAt(x, y)) return -1; ... return _xy(x, y); ... }
void IdentifySuccessors(...) { ... int jumpPoint = Jump(...); if(jumpPoint == -1) continue; short jumpPointX = _xyGetX(jumpPoint); short jumpPointY = _xyGetY(jumpPoint); ... }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Possible improvement for jump function.
Limits: x,y max values 0-32767 (0x7FFF)
How about instead of allocating memory every time you jump:
int *Jump(...) {
return int *i = (int *) malloc(2 * sizeof(int));
}
you could replace it with bit operations, and return int number instead (NULL will be equal to -1):
define _xy(x, y) ((x) | ((y) << 16))
define _xyGetX(i) ((i) & 0xFFFF)
define _xyGetY(i) ((i) >> 16)
int Jump(...) {
if(!IsWalkableAt(x, y))
return -1;
...
return _xy(x, y);
...
}
void IdentifySuccessors(...)
{
...
int jumpPoint = Jump(...);
if(jumpPoint == -1)
continue;
short jumpPointX = _xyGetX(jumpPoint);
short jumpPointY = _xyGetY(jumpPoint);
...
}
The text was updated successfully, but these errors were encountered: