Skip to content

Commit

Permalink
remove deepcopy method
Browse files Browse the repository at this point in the history
Signed-off-by: pulak-opti <[email protected]>
  • Loading branch information
pulak-opti committed Oct 29, 2024
1 parent 5ea39ee commit 353830d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
21 changes: 0 additions & 21 deletions pkg/decision/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,3 @@ type UserProfile struct {
ID string
ExperimentBucketMap map[UserDecisionKey]string
}

// DeepCopy creates a deep copy of the UserProfile.
func (up *UserProfile) DeepCopy() *UserProfile {
if up == nil {
return nil
}

userProfileCopy := UserProfile{
ID: up.ID,
}

// Deep copy the ExperimentBucketMap
if up.ExperimentBucketMap != nil {
userProfileCopy.ExperimentBucketMap = make(map[UserDecisionKey]string)
for k, v := range up.ExperimentBucketMap {
userProfileCopy.ExperimentBucketMap[k] = v
}
}

return &userProfileCopy
}
2 changes: 1 addition & 1 deletion pkg/decision/persisting_experiment_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (p PersistingExperimentService) getSavedDecision(decisionContext Experiment
if decisionContext.UserProfile == nil {
userProfile = p.userProfileService.Lookup(userContext.ID)
} else {
userProfile = *decisionContext.UserProfile.DeepCopy()
userProfile = *decisionContext.UserProfile
}

// look up experiment decision from user profile
Expand Down

0 comments on commit 353830d

Please sign in to comment.