Repository: etcd-io/etcd
File: tests/robustness/validate/patch_history.go (Go)

Code before:
						lastReturnTime = min(returnTime, lastReturnTime)
						putTimes[kv] = lastReturnTime
					}
				case model.DeleteOperation:
					kv := model.DeleteOptions{Key: op.Delete.Key}
					if clientDeleteCount[kv] > 1 {
						continue
					}
					if returnTime, ok := delTimes[kv]; ok {
						lastReturnTime = min(returnTime, lastReturnTime)
						delTimes[kv] = lastReturnTime
					}
				}
			}
		case model.LeaseGrant:
		case model.LeaseRevoke:
		case model.Compact:
			if lastReturnTime != math.MaxInt64 {
				lastReturnTime--
			}
			kv := model.CompactRequest{Revision: request.Compact.Revision}
			if clientCompactCount[kv] > 1 {
				continue
			}
			if returnTime, ok := compactTimes[kv]; ok {
				lastReturnTime = min(returnTime, lastReturnTime)
				compactTimes[kv] = lastReturnTime
			}
		default:
			panic(fmt.Sprintf("Unknown request type: %q", request.Type))
		}
	}
	return putTimes, delTimes, compactTimes
}

func countClientPuts(reports []report.ClientReport) map[model.PutOptions]int64 {
	counter := map[model.PutOptions]int64{}
	for _, client := range reports {
		for _, op := range client.KeyValue {
			request := op.Input.(model.EtcdRequest)
			countPuts(counter, request)
		}
	}
	return counter
}

func countPersistedPuts(requests []model.EtcdRequest) map[model.PutOptions]int64 {
	counter := map[model.PutOptions]int64{}
	for _, request := range requests {
		countPuts(counter, request)
	}

Review comment (suggestion):
```suggestion
			if lastReturnTime != math.MaxInt64 {
				lastReturnTime--
			}
			if clientCompactCount[request.Compact] > 1 {
				continue
			}
			if returnTime, ok := compactTimes[request.Compact]; ok {
				lastReturnTime = min(returnTime, lastReturnTime)
				compactTimes[request.Compact] = lastReturnTime
			}
```

Code after:
						putTimes[kv] = lastReturnTime
					}
				case model.DeleteOperation:
					kv := model.DeleteOptions{Key: op.Delete.Key}
					if clientDeleteCount[kv] > 1 {
						continue
					}
					if returnTime, ok := delTimes[kv]; ok {
						lastReturnTime = min(returnTime, lastReturnTime)
						delTimes[kv] = lastReturnTime
					}
				}
			}
		case model.LeaseGrant:
		case model.LeaseRevoke:
		case model.Compact:
			if lastReturnTime != math.MaxInt64 {
				lastReturnTime--
			}
			if clientCompactCount[*request.Compact] > 1 {
				continue
			}
			if returnTime, ok := compactTimes[*request.Compact]; ok {
				lastReturnTime = min(returnTime, lastReturnTime)
				compactTimes[*request.Compact] = lastReturnTime
			}
		default:
			panic(fmt.Sprintf("Unknown request type: %q", request.Type))
		}
	}
	return putTimes, delTimes, compactTimes
}

func countClientPuts(reports []report.ClientReport) map[model.PutOptions]int64 {
	counter := map[model.PutOptions]int64{}
	for _, client := range reports {
		for _, op := range client.KeyValue {
			request := op.Input.(model.EtcdRequest)
			countPuts(counter, request)
		}
	}
	return counter
}

func countPersistedPuts(requests []model.EtcdRequest) map[model.PutOptions]int64 {
	counter := map[model.PutOptions]int64{}
	for _, request := range requests {
		countPuts(counter, request)
	}
	return counter
}