Skip to content

Instantly share code, notes, and snippets.

@hborders
Created June 16, 2013 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hborders/5790859 to your computer and use it in GitHub Desktop.
Save hborders/5790859 to your computer and use it in GitHub Desktop.
Another "why" comment that is valuable. Without the comment, a naive developer might very declare the values at the call site, breaking the SWT library.
public static final int BUTTON_MASK;
public static final int MODIFIER_MASK;
static {
/*
* These values represent bit masks that may need to
* expand in the future. Therefore they are not initialized
* in the declaration to stop the compiler from inlining.
*/
BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3 | BUTTON4 | BUTTON5;
MODIFIER_MASK = ALT | SHIFT | CTRL | COMMAND;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment