Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mredolatti committed Jul 12, 2023
1 parent 4253b9f commit 5d527e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion splitio/commitversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ This file is created automatically, please do not edit
*/

// CommitVersion is the version of the last commit previous to release
const CommitVersion = "199471a"
const CommitVersion = "4253b9f"
23 changes: 11 additions & 12 deletions splitio/proxy/storage/optimized/changesummary.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ type SplitMinimalView struct {
type ChangeSummary struct {
Updated map[string]string // feature flag name -> trafficType
Removed map[string]string // feature flag name -> trafficType
Current splitSet // list of splits originally available at this point in time
Current *splitSet // list of splits originally available at this point in time
}

func newEmptyChangeSummary(ss *splitSet) ChangeSummary {
ns := newSplitSet()
if ss != nil {
ns = *ss
}
return ChangeSummary{Updated: map[string]string{}, Removed: map[string]string{}, Current: ns}
if ss == nil {
ss = newSplitSet()
}
return ChangeSummary{Updated: map[string]string{}, Removed: map[string]string{}, Current: ss}
}

func (c *ChangeSummary) applyChange(toAdd []SplitMinimalView, toRemove []SplitMinimalView) {
Expand Down Expand Up @@ -94,7 +93,7 @@ func (s *SplitChangesSummaries) AddChanges(added []dtos.SplitDTO, removed []dtos
}

var lastCheckpoint int64 = -1
var lastSplitSet splitSet
lastSplitSet := newSplitSet()
for key, summary := range s.changes {
if key > lastCheckpoint {
lastCheckpoint = key
Expand All @@ -109,7 +108,7 @@ func (s *SplitChangesSummaries) AddChanges(added []dtos.SplitDTO, removed []dtos

newSS := lastSplitSet.clone()
newSS.update(addedViews, removedViews)
s.changes[cn] = newEmptyChangeSummary(&newSS)
s.changes[cn] = newEmptyChangeSummary(newSS)
}

// AddOlderChange is used to add a change older than the oldest one currently stored (when the sync started)
Expand All @@ -127,7 +126,7 @@ func (s *SplitChangesSummaries) AddOlderChange(added []dtos.SplitDTO, removed []
s.removeOldestRecipe()
}

summary := newEmptyChangeSummary(nil) // TODO(mredolatti): see if we can do better than this
summary := newEmptyChangeSummary(nil) // TODO(mredolatti): see if we can do better than this
for _, split := range added {
summary.Updated[split.Name] = split.TrafficTypeName
}
Expand Down Expand Up @@ -202,11 +201,11 @@ type splitSet struct {
data map[string]struct{}
}

func newSplitSet() splitSet {
return splitSet{data: make(map[string]struct{})}
func newSplitSet() *splitSet {
return &splitSet{data: make(map[string]struct{})}
}

func (s *splitSet) clone() splitSet {
func (s *splitSet) clone() *splitSet {
x := newSplitSet()
for key := range s.data {
x.data[key] = struct{}{}
Expand Down

0 comments on commit 5d527e7

Please sign in to comment.