Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update math macros to avoid computing callable arguments more than once#140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Keating950 wants to merge4 commits intoarduino:master
base:master
Choose a base branch
Loading
fromKeating950:master

Conversation

Keating950
Copy link

This PR updates various math macros to avoid computing callable arguments more than once using the same technique that themax macro currently does. It also replaces them with C++ template functions when__cplusplus is defined.I originally opened this as in the ArduinoCore-avr repo, but was directed here.

❯ ./test-ArduinoCore-API===============================================================================All tests passed (527 assertions in 226 test cases)

Copy link
Collaborator

@matthijskooijmanmatthijskooijman left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for submitting this.

I left one small comment inline, and I would suggest moving all this code a bit further down, to where the current master defines min and max, in order to both minimize the diff (your current PR moves the definitions of min/max, which increases the diff) and to make sure this code is not inside theextern "C" block, removing the need for closing and reopening that block, which makes things cleaner as well.

@Keating950
Copy link
Author

Minimized the diff (I believe) as requested.

@codecov-io
Copy link

Codecov Report

Merging#140 (585f67a) intomaster (2af4a9c) willnot change coverage.
The diff coverage isn/a.

Impacted file tree graph

@@           Coverage Diff           @@##           master     #140   +/-   ##=======================================  Coverage   96.06%   96.06%           =======================================  Files          14       14             Lines         839      839           =======================================  Hits          806      806             Misses         33       33
Impacted FilesCoverage Δ
api/Common.h100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update2af4a9c...585f67a. Read thecomment docs.

@matthijskooijman
Copy link
Collaborator

Thanks! It's not exactly as I suggested yet, because:

  • You added indentation to the min/max macros, so, there's still a (IMHO unneeded) diff there. I would remove the indent again so these macros are not changed at all.
  • I also suggested (at least tried to) to move the rest of the functions and macros (constrain untilsq) down to wheremin andmax are defined, so they can share a singleifdef __cplusplus block, and are also in a place where you do not need to interrupt theextern "C" block.
  • It seems one of the commits also removes some trailing whitespace in from the twotemplate<class T, class L> lines for the min/max template functions, I'd also either revert that, or put it in a separate commit.

Ideally, you'd also squash all your commits together into a single commit (except maybe for whitespace-only changes, those would better be in separate commits), not sure if you're familiar with merging commits / rewriting history in git?

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign ourContributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let usrecheck it.

KOLANICH added a commit to KOLANICH-libs/ArduinoCore-avr that referenced this pull requestJul 26, 2022
…texpr functions in the case of C++. Required in order to avoid conflicts to C++ stdlib.Incorporates some of the changes fromarduino/ArduinoCore-API#140 andarduino/ArduinoCore-API@30e4397Co-Authored-By: Keating Reid <keating.reid@protonmail.com>Co-Authored-By: Martino Facchin <m.facchin@arduino.cc>
KOLANICH added a commit to KOLANICH-libs/ArduinoCore-avr that referenced this pull requestFeb 24, 2023
…texpr functions in the case of C++. Required in order to avoid conflicts to C++ stdlib.Incorporates some of the changes fromarduino/ArduinoCore-API#140 andarduino/ArduinoCore-API@30e4397Co-Authored-By: Keating Reid <keating.reid@protonmail.com>Co-Authored-By: Martino Facchin <m.facchin@arduino.cc>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@matthijskooijmanmatthijskooijmanmatthijskooijman left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@Keating950@codecov-io@matthijskooijman@CLAassistant

[8]ページ先頭

©2009-2025 Movatter.jp