Skip to content

Conversation

sthaha
Copy link
Collaborator

@sthaha sthaha commented Jun 11, 2025

Changes ZoneUsageMap from map[EnergyZone]*Usage to map[EnergyZone]Usage to eliminate shallow copy issues in Clone() methods. The Clone method itself is simpler and use value copy to copy
the non pointers there by eliminating the issue of forgetting to copy a member varible.

The original pointer-based maps caused Clone() methods to share Usage struct pointers between original and cloned objects. Modifying energy/ power values in a cloned object would unintentionally affect the original object.

Changes:

  • Change ZoneUsageMap type definition from map[EnergyZone]*Usage to map[EnergyZone]Usage
  • Update Usage struct assignments from &Usage{} to Usage{} in:

@github-actions github-actions bot added the fix A bug fix label Jun 11, 2025
Copy link

codecov bot commented Jun 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.59%. Comparing base (2e3afdf) to head (94aa157).
Report is 3 commits behind head on reboot.

Additional details and impacted files
@@            Coverage Diff             @@
##           reboot    #2143      +/-   ##
==========================================
- Coverage   81.76%   81.59%   -0.18%     
==========================================
  Files          37       37              
  Lines        3861     3846      -15     
==========================================
- Hits         3157     3138      -19     
- Misses        630      633       +3     
- Partials       74       75       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sthaha sthaha force-pushed the chore-improve-clone branch from 440bbf7 to 8f10d05 Compare June 11, 2025 07:36
@sthaha sthaha requested a review from vimalk78 June 11, 2025 07:37
@sthaha sthaha force-pushed the chore-improve-clone branch from 8f10d05 to 0589360 Compare June 11, 2025 07:50
Changes ZoneUsageMap from map[EnergyZone]*Usage to map[EnergyZone]Usage
to eliminate shallow copy issues in Clone() methods.

The original pointer-based maps caused Clone() methods to share Usage
struct pointers between original and cloned objects. Modifying energy/
power values in a cloned object would unintentionally affect the
original object.

Changes:
- Change ZoneUsageMap type definition from map[EnergyZone]*Usage to map[EnergyZone]Usage
- Update Usage struct assignments from &Usage{} to Usage{} in:

Signed-off-by: Sunil Thaha <sthaha@redhat.com>
@sthaha sthaha force-pushed the chore-improve-clone branch from 0589360 to 94aa157 Compare June 11, 2025 08:03
@vimalk78 vimalk78 merged commit 66f99f3 into sustainable-computing-io:reboot Jun 11, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants