Uploaded image for project: 'Commons RNG'
  1. Commons RNG
  2. RNG-169

Update array seed conversion to use optimum seed length

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Implemented
    • 1.4
    • 1.5
    • simple
    • None

    Description

      The seed conversion routines in ByteArray2LongArray and ByteArray2IntArray can be optimised for memory usage.

      The converters can be updated to implement Seed2ArrayConverter. This allows the length of the output seed to be constructed to the correct length. This will avoid converting part of the byte[] seed that is not used.

      In addition the input seed is expanded if it is not modulus 8 or 4 respectively using Arrays.copyOf. This will zero fill the end of the seed. The array can then be converted by the NumberFactory without an exception.

      These routines should be updated to use the same method as NumberFactory to fill in a long[] and then add any trailing bytes to the final long.

      This avoids any array copy when using arbitrary seed lengths, e.g. SecureRandom.getSeed(13).

      Attachments

        Activity

          People

            Unassigned Unassigned
            aherbert Alex Herbert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: