Skip to content

Commit

Permalink
Make some ModelIO instance fields constants (#2050)
Browse files Browse the repository at this point in the history
The initialisation of these two fields showed up in performance testing,
since we create quite a few ModelIO-based objects when parsing or
serializing and SmallRyeOASModels populates a large map in its
constructor.
  • Loading branch information
Azquelt authored Oct 30, 2024
1 parent 148613d commit 61225d8
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,13 @@ protected boolean setProperty(T model, AnnotationValue value) {

public abstract T read(AnnotationInstance annotation);

private SmallRyeOASModels modelTypes = new SmallRyeOASModels();
private static final SmallRyeOASModels MODEL_TYPES = new SmallRyeOASModels();

@SuppressWarnings("unchecked")
public <C extends Constructible> T readObject(Class<C> type, O node) {
var jsonIO = jsonIO();
BaseModel<C> model = (BaseModel<C>) OASFactory.createObject(type);
var modelType = modelTypes.getModel(type);
var modelType = MODEL_TYPES.getModel(type);

for (Map.Entry<String, V> property : jsonIO.properties(node)) {
String name = property.getKey();
Expand Down Expand Up @@ -383,7 +383,7 @@ public Optional<? extends V> write(T model) {
throw new UnsupportedOperationException(getClass() + "#write(T)");
}

Set<String> REF_PROPERTIES = Set.of(ReferenceIO.REF, "summary", "description");
private static final Set<String> REF_PROPERTIES = Set.of(ReferenceIO.REF, "summary", "description");

@Override
@SuppressWarnings("unchecked")
Expand Down

0 comments on commit 61225d8

Please sign in to comment.