Skip to content

Conversation

badasahog
Copy link
Contributor

Temporary objects are unnecessary, especially when derived from a const pointer.

I think this creates an improvement in readability, as the code becomes more self documenting.

I would also add that potentially we should make the pointer idxp a restrict qualification (if safe) and a more descript name.

I don't know exactly what it's for tho, so I'm useless there.

Copy link

codecov bot commented Aug 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.79%. Comparing base (1320863) to head (fbcf862).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7238      +/-   ##
==========================================
- Coverage   98.79%   98.79%   -0.01%     
==========================================
  Files          81       81              
  Lines       15254    15247       -7     
==========================================
- Hits        15070    15063       -7     
  Misses        184      184              

☔ 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.

Copy link

github-actions bot commented Aug 7, 2025

No obvious timing issues in HEAD=replaceWithSubscript
Comparison Plot

Generated via commit fbcf862

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 2 minutes and 53 seconds
Installing different package versions 40 seconds
Running and plotting the test cases 2 minutes and 36 seconds

anyNA |= elem==NA_INTEGER;
anyLess |= elem<last;
last = elem;
if (idxp[i]<=0 && idxp[i]!=NA_INTEGER) return "Internal inefficiency: idx contains negatives or zeros. Should have been dealt with earlier."; // e.g. test 762 (TODO-fix)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one in particular looks useful as a local variable, rather than reading idxp[i] 6 more times.

Is there an advantage of idxp[i] over just adding const here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idxp is already a pointer to const, so idxp[i] would likely be held in a register.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Likely" may not be best reason for change that doesn't really do much. If it is more readable is also questionable... x[y[i]] IMO is less readable than x[yi]

@MichaelChirico
Copy link
Member

I think this creates an improvement in readability, as the code becomes more self documenting.

I'm not sure about this, could you elaborate? Any external reference you can point to?

@badasahog
Copy link
Contributor Author

It's more obvious where the data comes from, instead of adding a temporary object which adds another level of unnecessary abstraction.

@badasahog badasahog mentioned this pull request Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants