Skip to content

Change operator< from FairTimeStamp* to FairTimeStamp&#1526

Merged
fuhlig1 merged 1 commit intodevfrom
TobiasStockmanns-patch-1
May 14, 2024
Merged

Change operator< from FairTimeStamp* to FairTimeStamp&#1526
fuhlig1 merged 1 commit intodevfrom
TobiasStockmanns-patch-1

Conversation

@TobiasStockmanns
Copy link
Copy Markdown
Contributor

@TobiasStockmanns TobiasStockmanns commented Apr 22, 2024

The behaviour of the FairTimeStamp::operator< does no follow standard behaviour by dealing with the FairTimeStamp* instead of a FairTimeStamp&. This is fixed in this merge request.
Should fix issue #1519.

Describe your proposal.

Mention any issue this PR resolves or is related to.


Checklist:

Summary by CodeRabbit

  • Refactor
    • Improved the comparison operation in the FairTimeStamp class for enhanced reliability and performance.
    • Updated the CHANGELOG.md file.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 22, 2024

Walkthrough

Walkthrough

The update to the FairTimeStamp class involves transitioning the operator< method to utilize a reference parameter instead of a pointer. This change enhances code clarity and efficiency by directly utilizing the fTimeStamp member variable for comparisons.

Changes

File Path Change Summary
.../event/FairTimeStamp.h Modified operator< to use a reference parameter in FairTimeStamp.

Possibly related issues


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 44391b2 and 4d4707c.
Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • fairroot/base/event/FairTimeStamp.h (2 hunks)
Additional Context Used
LanguageTool (18)
CHANGELOG.md (18)

Near line 13: Unpaired symbol: ‘]’ seems to be missing
Context: ...# Breaking Changes * CMake * Dropped [our custom FindROOT.cmake](https://git...


Near line 53: ‘was in conflict with’ might be wordy. Consider a shorter alternative.
Context: ...pped build switch BUILD_UNITTESTS, it was in conflict with the CMake standard switch [`BUILD_T...


Near line 54: Unpaired symbol: ‘]’ seems to be missing
Context: ...lict with the CMake standard switch [BUILD_TESTING from the CTest module](h...


Near line 146: Consider inserting a comma after an introductory phrase for better readability.
Context: ...es * Allow running without output sink. In this case even persistent branches would not be s...


Near line 154: A comma may be missing after the conjunctive/linking adverb ‘Also’.
Context: ... the Base into the Online library. * Also the MBS/LMD related source classes were...


Near line 156: With the singular noun ‘one’, use the verb “is”.
Context: ...ne library. * If one of these classes are used in your code, you need to link...


Near line 174: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... being set, rewrite it accordingly. * If your code has specific C++ needs, consi...


Near line 175: Possible missing comma found.
Context: ... CMake's target_compile_features(). * Dropped CHECK_EXTERNAL_PACKAGE_INSTALL_DIR ...


Near line 177: This word is normally spelled as one.
Context: ...USE_PATH_INFO CMake option. It was an anti-pattern. Don't use it! * Dropped `ROOT_GENERATE...


Near line 193: The word “opt-in” is a noun. The verb is spelled with a space.
Context: ...on Boost.Serialization. The user must opt-in to the previously baseline Boost serial...


Near line 193: You used an adverb (‘previously’) instead of an adjective, or a noun (‘baseline’) instead of another adjective.
Context: ...ialization. The user must opt-in to the previously baseline Boost serialization support by includ...


Near line 206: The conjunction “so that” does not have a comma in front.
Context: ...y require some API, please file an issue, so that we can see how to handle this. * Depre...


Near line 218: Loose punctuation mark.
Context: ...tion. * FairRadMapManager::Instance, FairRadLenManager::Instance *Fair...


Near line 222: Loose punctuation mark.
Context: ...thing. * FairTask::*InputPersistance: There's no getter for `fInputPersis...


Near line 229: Loose punctuation mark.
Context: ...ConstructASCIIGeometry(T*, TString, U*), use FairModule::ConstructASCIIGeom...


Near line 255: Possible missing comma found.
Context: ...se` style naming. For those using the targets this change will not be visible. * Test...


Near line 256: If the ‘because’ clause is essential to the meaning, do not use a comma before the clause.
Context: ...ing Geant3 have been disabled by default, because those tests have a probability > 0 fo...


Near line 258: The word ‘anyways’ is informal American English. Did you mean “anyway”?
Context: ... for failing. If you want to run them anyways, pass -DENABLE_GEANT3_TESTING=ON to...

Additional comments not posted (1)
fairroot/base/event/FairTimeStamp.h (1)

77-77: Change in operator< from pointer to reference type is correctly implemented.

This change simplifies the comparison logic and aligns with C++ best practices by avoiding pointer arithmetic and potential null pointer dereferencing issues.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment thread fairroot/base/event/FairTimeStamp.h Outdated
@fuhlig1
Copy link
Copy Markdown
Member

fuhlig1 commented Apr 24, 2024

@TobiasStockmanns,

I don't understand why the operator is needed at all. I is neither used in FairRoot nor PandaRoot which was checked by Radek and me independently. Radek simply removed the function, I add the function with =delete. In both cases we did not see any compilation errors. To cross-check I add a test which uses the operator< and this file shows the following error message during compilation

/opt/fairroot/source/v19.0/tests/base/event/test_FairTimeStamp.cxx:20:9: error: overload resolution selected deleted operator '<'
   if (a<b) { a=2.;}
       ~^~
/opt/fairroot/source/v19.0/fairroot/base/event/FairTimeStamp.h:63:11: note: candidate function has been explicitly deleted
     bool operator<(const FairTimeStamp& rValue) = delete;
          ^
/opt/fairsoft/jan24/include/root/TString.h:778:15: note: candidate function not viable: no known conversion from 'FairTimeStamp' to 'const TString' for 1st argument
inline Bool_t operator<(const TString &s1, const TString &s2)
              ^
/opt/fairsoft/jan24/include/root/TString.h:794:15: note: candidate function not viable: no known conversion from 'FairTimeStamp' to 'const TString' for 1st argument
inline Bool_t operator<(const TString &s1, const char *s2)
              ^
/opt/fairsoft/jan24/include/root/TString.h:812:15: note: candidate function not viable: no known conversion from 'FairTimeStamp' to 'const char *' for 1st argument
inline Bool_t operator<(const char *s1, const TString &s2)
              ^
/opt/fairroot/source/v19.0/fairroot/base/event/FairTimeStamp.h:64:11: note: candidate function not viable: no known conversion from 'FairTimeStamp' to 'const FairTimeStamp *' for 1st argument; take the address of the argument with &
     bool operator<(const FairTimeStamp* rValue) = delete;
          ^

I don't see the need for the overloaded function and would propose to simply delete it or at least set it as deprecated.

@TobiasStockmanns
Copy link
Copy Markdown
Contributor Author

The original idea why I defined bool operator<(const FairTimeStamp* rValue) was to be able to sort a container of FairTimeStamp* with this operator. Unfortunately this does not work because the sort will always use the memory location and not the FairTimeStamp::operator<. So this implementation does not make any sense.
Nevertheless I think it is good to have an bool operator<(const FairTimeStamp& rValue) defined, because for time based simulations and reconstructions a sorting by the time stamp is mandatory and this should be supported by the code.
In addition the virtual should be removed.

karabowi
karabowi previously approved these changes Apr 29, 2024
Copy link
Copy Markdown
Member

@ChristianTackeGSI ChristianTackeGSI left a comment

Choose a reason for hiding this comment

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

Still some open points

Comment thread fairroot/base/event/FairTimeStamp.h Outdated
@karabowi
Copy link
Copy Markdown
Collaborator

@coderabbitai construct short CHANGELOG message for this PR.
@TobiasStockmanns , can you squash into one commit?

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 30, 2024

Tip

For best results, initiate chat on the files or code changes.

@karabowi, here's a short CHANGELOG message for PR #1526:

- Updated `FairTimeStamp::operator<` to use references instead of pointers, aligning with standard C++ practices and enhancing safety. This change supports accurate timestamp-based sorting in simulations and reconstructions.

Let me know if you need any further modifications or additional information!

Comment thread fairroot/base/event/FairTimeStamp.h Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Out of diff range and nitpick comments (5)
CHANGELOG.md (5)

Line range hint 15-17: Consider using Markdown links instead of bare URLs for better readability and consistency with Markdown standards.

- * Dropped [our custom `FindROOT.cmake`](https://github.com/FairRootGroup/FairRoot/commit/764b2c66432d2e63f765df6f6d328aa4b61dba10)
+ * Dropped [our custom `FindROOT.cmake`](https://github.com/FairRootGroup/FairRoot/commit/764b2c66432d2e63f765df6f6d328aa4b61dba10)

Line range hint 53-53: Consider rephrasing "was in conflict with" to a more concise alternative like "conflicted with" to enhance readability.

- * Dropped build switch `BUILD_UNITTESTS`, it was in conflict with the CMake standard switch [`BUILD_TESTING` from the CTest module](https://cmake.org/cmake/help/latest/module/CTest.html)
+ * Dropped build switch `BUILD_UNITTESTS`, it conflicted with the CMake standard switch [`BUILD_TESTING` from the CTest module](https://cmake.org/cmake/help/latest/module/CTest.html)

Line range hint 157-157: Grammar correction: Replace "are" with "is" to match the singular noun "one".

- * If one of these classes are used in your code, you need to link against new target `FairRoot::Online`.
+ * If one of these classes is used in your code, you need to link against new target `FairRoot::Online`.

Line range hint 194-194: The verb form of "opt-in" should be "opt in". Additionally, consider replacing "previously baseline" with "previously standard" for clarity.

- * Boost serialization support for `FairTimeStamp`, `FairHit`, and `FairMCPoint` has been moved to the `FairRoot::BaseMQ` target to have `FairRoot::Base` no longer depend on Boost.Serialization. The user must opt-in to the previously baseline Boost serialization support by including one of the new headers, e.g. for `FairHit`:
+ * Boost serialization support for `FairTimeStamp`, `FairHit`, and `FairMCPoint` has been moved to the `FairRoot::BaseMQ` target to have `FairRoot::Base` no longer depend on Boost.Serialization. The user must opt in to the previously standard Boost serialization support by including one of the new headers, e.g. for `FairHit`:

Line range hint 259-259: Replace "anyways" with "anyway" for formal writing.

- * If you want to run them anyways, pass `-DENABLE_GEANT3_TESTING=ON` to CMake.
+ * If you want to run them anyway, pass `-DENABLE_GEANT3_TESTING=ON` to CMake.

Comment thread CHANGELOG.md Outdated
Copy link
Copy Markdown
Member

@ChristianTackeGSI ChristianTackeGSI left a comment

Choose a reason for hiding this comment

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

Please rebase and squash things.

Comment thread CHANGELOG.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Copy link
Copy Markdown
Member

@ChristianTackeGSI ChristianTackeGSI left a comment

Choose a reason for hiding this comment

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

Please rebase and squash things.

The behaviour of the FairTimeStamp::operator< does no follow standard
behaviour by dealing with the FairTimeStamp* instead of a FairTimeStamp&.
This is fixed in this merge request.

Should fix issue #1519.
@karabowi karabowi force-pushed the TobiasStockmanns-patch-1 branch from 44391b2 to 4d4707c Compare May 13, 2024 11:18
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Comment thread CHANGELOG.md
@karabowi
Copy link
Copy Markdown
Collaborator

Please rebase and squash things.

Done.

@fuhlig1 fuhlig1 merged commit 5470270 into dev May 14, 2024
@fuhlig1 fuhlig1 deleted the TobiasStockmanns-patch-1 branch May 14, 2024 07:00
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.

4 participants