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

Speed up unread enum parsing #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ public final class EnumDefinition extends SimpleDatatypeDefinition {

private static final String UNKNOWN_ENUM = "<unknown> (%s)"; //$NON-NLS-1$

private static final String UNINITIALIZED = "UNINITIALIZED"; //$NON-NLS-1$

private final IntegerDefinition fInteger;

private final @Nullable String fValue;
private @Nullable String fValue;

// ------------------------------------------------------------------------
// Constructors
Expand All @@ -59,9 +61,9 @@ public final class EnumDefinition extends SimpleDatatypeDefinition {
public EnumDefinition(@NonNull EnumDeclaration declaration,
IDefinitionScope definitionScope, @NonNull String fieldName, IntegerDefinition intValue) {
super(declaration, definitionScope, fieldName);

fInteger = intValue;
fValue = declaration.query(fInteger.getValue());
fValue = UNINITIALIZED;

}

// ------------------------------------------------------------------------
Expand All @@ -75,6 +77,9 @@ public EnumDefinition(@NonNull EnumDeclaration declaration,
* @return the value of the enum.
*/
public String getValue() {
if (fValue == UNINITIALIZED) {
fValue = getDeclaration().query(fInteger.getValue());
}
return fValue != null ? fValue : String.format(UNKNOWN_ENUM, getIntegerValue());
}

Expand Down
Loading