Skip to content

Don't allocate unnecessary annotation arrays in IonValueLite's copy constructor #1051

Description

@tgregg

https://github.com/amazon-ion/ion-java/blob/master/src/main/java/com/amazon/ion/impl/lite/IonValueLite.java#L305

Currently, this array is allocated even in the following situations:

  1. When the array to be copied has length 0
  2. When the array to be copied has length > 0 but only null elements

This should be optimized by waiting to allocate the array until at least one non-null element is found, and using a constant SymbolToken[0] when no annotations are present.

Further, we should double-check the logic that causes an array with length > 0 and only null elements to exist, to make sure it is not being wastefully over-allocated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions