From 008773dc77d8a84ef7d630be97bae5ae7cc39c9c Mon Sep 17 00:00:00 2001 From: Igor Labutin Date: Sat, 1 Jul 2017 01:56:50 +0300 Subject: [PATCH] Fixed HistoryDictionary to avoid keeping identical timestamps for given ID. The newest value wins. --- src/TraceEvent/TraceUtilities/HistoryDictionary.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/TraceEvent/TraceUtilities/HistoryDictionary.cs b/src/TraceEvent/TraceUtilities/HistoryDictionary.cs index c1dd4462e..6c423e941 100644 --- a/src/TraceEvent/TraceUtilities/HistoryDictionary.cs +++ b/src/TraceEvent/TraceUtilities/HistoryDictionary.cs @@ -40,11 +40,20 @@ public void Add(Address id, long startTime, T value, bool isEndRundown = false) // See if we can jump ahead. Currently we only do this of the first entry, // But you could imagine using some of the other nodes's skipAhead entries. - if (firstEntry.skipAhead != null && firstEntry.skipAhead.startTime < startTime) + if (firstEntry.skipAhead != null && firstEntry.skipAhead.startTime <= startTime) entry = firstEntry.skipAhead; for (; ; ) { + // We found exact match + if (startTime == entry.StartTime) + { + // Just update the value and exit immediately as there is no need to + // update skipAhead or increment count + entry.value = value; + return; + } + if (entry.next == null) { entry.next = new HistoryValue(startTime, id, value);