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

Improve performance of Time to/from JSON #114

Closed
wants to merge 5 commits into from

Commits on Jan 9, 2018

  1. Configuration menu
    Copy the full SHA
    7b82396 View commit details
    Browse the repository at this point in the history
  2. Eliminate two memory allocations in Time.MarshalJSON

    Converting from string to []byte makes a copy, as strings are
    immutable and slices are not. Creating a byte slice using
    AppendFloat() instead of FormatFloat() avoids creating both the string
    and the copy.
    bboreham committed Jan 9, 2018
    Configuration menu
    Copy the full SHA
    41ade24 View commit details
    Browse the repository at this point in the history
  3. Eliminate a memory allocation in Time.UnarshalJSON

    Split() uses heap storage for the result array: since we never want
    more than two parts we can just use IndexByte() to find the split.
    And we don't need a check for the case with more than one '.' since
    ParseInt() will error.
    bboreham committed Jan 9, 2018
    Configuration menu
    Copy the full SHA
    4b3219c View commit details
    Browse the repository at this point in the history
  4. Pre-allocate a string of zeros for Time.UnmarshalJSON

    For performance: it saves one or two allocations every time you hit
    this path.
    bboreham committed Jan 9, 2018
    Configuration menu
    Copy the full SHA
    9a7a45c View commit details
    Browse the repository at this point in the history

Commits on Jan 19, 2018

  1. Configuration menu
    Copy the full SHA
    66e9e60 View commit details
    Browse the repository at this point in the history