Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16273


Ignore:
Timestamp:
11/04/18 10:56:46 (6 years ago)
Author:
bburlacu
Message:

#2950: Improve hashing performance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/HashExtensions.cs

    r16272 r16273  
    8282      var node = nodes[i];
    8383      const int size = sizeof(ulong);
    84       var hashes = new byte[(node.Arity + 1) * size];
     84      var hashes = new ulong[node.Arity + 1];
     85      var bytes = new byte[(node.Arity + 1) * size];
    8586
    8687      for (int j = i - 1, k = 0; k < node.Arity; ++k, j -= 1 + nodes[j].Size) {
    87         Array.Copy(BitConverter.GetBytes(nodes[j].CalculatedHashValue), 0, hashes, k * size, size);
    88       }
    89       Array.Copy(BitConverter.GetBytes(node.HashValue), 0, hashes, node.Arity * size, size);
    90       return hashFunction(hashes);
     88        hashes[k] = nodes[j].CalculatedHashValue;
     89      }
     90      hashes[node.Arity] = node.HashValue;
     91      Buffer.BlockCopy(hashes, 0, bytes, 0, bytes.Length);
     92      return hashFunction(bytes);
    9193    }
    9294
Note: See TracChangeset for help on using the changeset viewer.