Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace builtin map by ordered map for deterministic iteration #2

Merged
merged 11 commits into from
Jul 18, 2024

Conversation

bdeneux
Copy link

@bdeneux bdeneux commented Jul 5, 2024

📝 Description

Following the issue concerning the random display order of predicates listed by current_predicate/1 in the Axone Protocol chain (refer to Issue #695 for more details), this PR implements a significant modification to the underlying data structure that maintains the list of registered procedures. Specifically, it replaces the conventional map with an ordered map.

The decision to adopt the second solution proposed in the issue (switching to an ordered map instead of sorting the procedures map before returning results) was driven by the foundational role of the procedures map in predicate operations. Ensuring consistent behavior across nodes necessitates a stable base for all predicates. This change guarantees that if any predicate relies on the map's order, it will operate on a consistent and predictable foundation, thereby enhancing the reliability and predictability of predicate executions across the network.

🔀 Ordered map libraries

I have explored several libraries that provide ordered map functionality in Go:

  • https://github.com/elliotchance/orderedmap
  • https://github.com/wk8/go-ordered-map
  • https://github.com/emirpasic/gods
  • among others.

After careful consideration, I decided to use https://github.com/wk8/go-ordered-map due to its minimalistic approach and efficiency. The decision was further reinforced by the library's comprehensive comparison with alternatives, detailed at https://github.com/wk8/go-ordered-map?tab=readme-ov-file#alternatives. Initially, I had opted for https://github.com/elliotchance/orderedmap, but encountered difficulties when attempting to compare two ordered maps in a testing scenario.

Impact

Three maps has been impacted on the refactoring and replaced by an ordered map.

  • Procedures map
  • Clauses map
  • Operators map

🔗 Related links

Copy link

coderabbitai bot commented Jul 5, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduce several upgrades and enhancements, including updating the codecov-action in GitHub workflows and transitioning from standard maps to ordered maps in the engine package. This transition affects the way operators and procedures are managed and accessed, aiming for more efficient and predictable ordering in operations.

Changes

Files Change Summary
.github/workflows/go.yml Upgraded codecov/codecov-action from v2.1.0 to v4 and added token configuration with a secret.
engine/atom.go, engine/compound.go, ... Updated methods to use getOps() for accessing operations.
engine/atom_test.go, engine/compound_test.go Updated test initializations to use orderedmap for operators.
engine/builtin.go Switched vm.procedures to an orderedmap and adjusted method calls accordingly.
engine/parser.go, engine/parser_test.go Transitioned operators to use an OrderedMap and updated Parser struct to utilize a pointer to _operators.
engine/term.go Changed ops field in WriteOptions to _ops as a pointer to operators and introduced getOps() method.
engine/text.go, engine/text_test.go, ... Updated storage for procedures to use ordered map and adjusted relevant methods for procedure management.

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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configuration 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.

@bdeneux bdeneux force-pushed the feat/sorted-map-procedures branch from c198adc to b4c92d8 Compare July 7, 2024 20:44
@bdeneux bdeneux marked this pull request as ready for review July 8, 2024 07:26
Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0e87b1e and 9185fe4.

Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
Files selected for processing (7)
  • engine/builtin.go (7 hunks)
  • engine/builtin_test.go (31 hunks)
  • engine/dcg_test.go (1 hunks)
  • engine/text.go (2 hunks)
  • engine/text_test.go (3 hunks)
  • engine/vm.go (5 hunks)
  • engine/vm_test.go (10 hunks)
Additional comments not posted (81)
engine/dcg_test.go (1)

14-22: LGTM!

The initialization of the VM struct with an ordered map using buildOrderedMap ensures consistent procedure order. The changes are appropriate.

engine/text.go (4)

6-6: LGTM!

The import of github.com/wk8/go-ordered-map/v2 is necessary for the changes and is correctly added.


32-32: LGTM!

The initialization of vm.procedures with an ordered map ensures consistent procedure order.


35-36: LGTM!

The usage of getProcedure to retrieve procedures aligns with the new ordered map structure.


41-41: LGTM!

The usage of setProcedure to set procedures aligns with the new ordered map structure.

engine/vm_test.go (10)

16-16: LGTM!

The usage of Get to retrieve the procedure for arity: 0 aligns with the new ordered map structure.


38-38: LGTM!

The usage of Get to retrieve the procedure for arity: 1 aligns with the new ordered map structure.


58-58: LGTM!

The usage of Get to retrieve the procedure for arity: 2 aligns with the new ordered map structure.


78-78: LGTM!

The usage of Get to retrieve the procedure for arity: 3 aligns with the new ordered map structure.


98-98: LGTM!

The usage of Get to retrieve the procedure for arity: 4 aligns with the new ordered map structure.


118-118: LGTM!

The usage of Get to retrieve the procedure for arity: 5 aligns with the new ordered map structure.


138-138: LGTM!

The usage of Get to retrieve the procedure for arity: 6 aligns with the new ordered map structure.


158-158: LGTM!

The usage of Get to retrieve the procedure for arity: 7 aligns with the new ordered map structure.


178-178: LGTM!

The usage of Get to retrieve the procedure for arity: 8 aligns with the new ordered map structure.


196-203: LGTM!

The initialization of the VM struct with an ordered map using buildOrderedMap ensures consistent procedure order. The changes are appropriate.

engine/vm.go (14)

6-6: LGTM!

The import of github.com/wk8/go-ordered-map/v2 is necessary for the changes and is correctly added.


55-55: LGTM!

The VM struct now uses an ordered map for procedures, ensuring consistent order.


80-82: LGTM!

The initialization of vm.procedures with an ordered map in Register0 ensures consistent procedure order.


88-90: LGTM!

The initialization of vm.procedures with an ordered map in Register1 ensures consistent procedure order.


96-98: LGTM!

The initialization of vm.procedures with an ordered map in Register2 ensures consistent procedure order.


104-106: LGTM!

The initialization of vm.procedures with an ordered map in Register3 ensures consistent procedure order.


112-114: LGTM!

The initialization of vm.procedures with an ordered map in Register4 ensures consistent procedure order.


120-122: LGTM!

The initialization of vm.procedures with an ordered map in Register5 ensures consistent procedure order.


128-130: LGTM!

The initialization of vm.procedures with an ordered map in Register6 ensures consistent procedure order.


136-138: LGTM!

The initialization of vm.procedures with an ordered map in Register7 ensures consistent procedure order.


144-146: LGTM!

The initialization of vm.procedures with an ordered map in Register8 ensures consistent procedure order.


181-181: LGTM!

The usage of getProcedure in Arrive aligns with the new ordered map structure.


306-311: LGTM!

The getProcedure method ensures safe retrieval of procedures from the ordered map.


313-318: LGTM!

The setProcedure method ensures safe assignment of procedures to the ordered map.

engine/text_test.go (15)

32-32: LGTM!

The change to use orderedmap for the result field ensures consistent ordering of procedures.


54-70: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


74-98: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


102-190: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


195-221: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


226-259: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


265-305: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


308-339: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


342-373: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


376-393: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


396-413: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


489-506: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.


514-514: LGTM!

The function TestVM_Consult is unchanged.


Line range hint 561-561: LGTM!

The function TestDiscontiguousError_Error is unchanged.


36-52: Ensure buildOrderedMap is correctly implemented.

The code snippet uses the buildOrderedMap function to initialize the orderedmap. Verify the correctness of this function to ensure it constructs the map as expected.

Verification successful

Let's inspect the implementation of the buildOrderedMap function to verify its correctness.


Verification Successful: buildOrderedMap is correctly implemented.

The function correctly constructs an ordered map using the provided procedurePair elements.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of buildOrderedMap function.

# Test: Search for the function implementation. Expect: Correct implementation of buildOrderedMap.
rg --type go 'func buildOrderedMap' 

Length of output: 161


Script:

#!/bin/bash
# Fetch the implementation details of the buildOrderedMap function
rg --type go --context 10 'func buildOrderedMap' 

Length of output: 1039

engine/builtin.go (12)

7-7: Import statement for ordered map.

The import statement for orderedmap is necessary for the changes.


705-705: Initialize procedures with an ordered map.

The vm.procedures map is correctly initialized with an ordered map.


707-707: Retrieve procedure using getProcedure method.

The use of the getProcedure method abstracts the retrieval process, enhancing maintainability.


710-710: Set procedure using setProcedure method.

The use of the setProcedure method abstracts the setting process, enhancing maintainability.


1070-1070: Initialize slice with the length of the ordered map.

The slice is correctly initialized with the length of the ordered map, ensuring optimal performance.


1071-1071: Iterate over the ordered map using Oldest method.

The iteration over the ordered map using the Oldest method ensures consistent and predictable order.


1074-1074: Append functions based on ordered map's values.

The functions are correctly appended based on the ordered map's values, ensuring the correct order.


1095-1095: Retrieve procedure using getProcedure method.

The use of the getProcedure method abstracts the retrieval process, enhancing maintainability.


1146-1146: Retrieve procedure using getProcedure method.

The use of the getProcedure method abstracts the retrieval process, enhancing maintainability.


1150-1150: Delete procedure from ordered map.

The procedure is correctly deleted from the ordered map.


1987-1987: Retrieve procedure using getProcedure method.

The use of the getProcedure method abstracts the retrieval process, enhancing maintainability.


2754-2754: Retrieve procedure using getProcedure method.

The use of the getProcedure method abstracts the retrieval process, enhancing maintainability.

engine/builtin_test.go (25)

10-10: Import statement for ordered map library looks good.

The import of github.com/wk8/go-ordered-map/v2 is necessary for the changes.


21-22: Type alias procedurePair looks good.

Defining a type alias for orderedmap.Pair[procedureIndicator, procedure] simplifies the code.


97-102: Initialization of VM with ordered map looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


129-134: Initialization of VM with ordered map for arity 3 looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


161-166: Initialization of VM with ordered map for arity 4 looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


193-198: Initialization of VM with ordered map for arity 5 looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


225-230: Initialization of VM with ordered map for arity 6 looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


257-262: Initialization of VM with ordered map for arity 7 looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


289-294: Initialization of VM with ordered map for arity 8 looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


304-317: Initialization of VM with ordered map in TestCallNth looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


2459-2466: Initialization of VM with ordered map in TestCurrentPredicate looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


2483-2497: Initialization of VM with ordered map in TestCurrentPredicate with multiple procedures looks good.

The use of buildOrderedMap to initialize the VM struct with multiple procedures is correct.


2525-2573: Initialization of VM with ordered map in TestCurrentPredicate with order checks looks good.

The use of buildOrderedMap to initialize the VM struct with multiple procedures and the order checks are correct.


2693-2696: Retrieval of procedure pair using GetPair in TestCurrentPredicate looks good.

The use of GetPair to retrieve the procedure pair is correct.


2760-2765: Initialization of VM with ordered map in TestAbolish looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


2820-2820: Retrieval of procedure pair using GetPair in TestAbolish looks good.

The use of GetPair to retrieve the procedure pair is correct.


2894-2894: Retrieval of procedure pair using GetPair in TestAbolish looks good.

The use of GetPair to retrieve the procedure pair is correct.


2966-2971: Initialization of VM with ordered map in TestAbolish looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


3002-3011: Initialization of VM with ordered map in TestRetract looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


3029-3038: Initialization of VM with ordered map in TestRetract with multiple procedures looks good.

The use of buildOrderedMap to initialize the VM struct with multiple procedures is correct.


3056-3065: Initialization of VM with ordered map in TestRetract with multiple procedures looks good.

The use of buildOrderedMap to initialize the VM struct with multiple procedures is correct.


3074-3075: Retrieval of procedure using Get in TestRetract looks good.

The use of Get to retrieve the procedure is correct.


3105-3108: Initialization of VM with ordered map in TestRetract looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


3121-3128: Initialization of VM with ordered map in TestRetract looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.


3149-3158: Initialization of VM with ordered map in TestAbolish looks good.

The use of buildOrderedMap to initialize the VM struct with procedures is correct.

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9185fe4 and 6d6c54d.

Files selected for processing (1)
  • engine/vm.go (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • engine/vm.go

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6d6c54d and 814c243.

Files selected for processing (1)
  • engine/text_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • engine/text_test.go

@bdeneux bdeneux force-pushed the feat/sorted-map-procedures branch from 814c243 to e8116d8 Compare July 8, 2024 12:10
Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 814c243 and e8116d8.

Files selected for processing (1)
  • engine/text_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • engine/text_test.go

@bdeneux bdeneux requested review from ccamel and amimart July 8, 2024 12:13
@bdeneux bdeneux self-assigned this Jul 8, 2024
@bdeneux bdeneux removed request for ccamel and amimart July 9, 2024 12:20
@bdeneux bdeneux marked this pull request as draft July 9, 2024 12:22
@bdeneux bdeneux changed the title Use ordered map for procedures map Replace builtin map by ordered map for deterministic iteration Jul 12, 2024
Copy link

codecov bot commented Jul 12, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@bdeneux bdeneux marked this pull request as ready for review July 12, 2024 09:37
Copy link

@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: 2

Outside diff range, codebase verification and nitpick comments (1)
engine/term.go (1)

23-23: Add a comment to explain _ops field.

Consider adding a comment to explain the purpose of _ops field in the WriteOptions struct for better clarity.

	_ops        *operators // Ordered map for storing operators
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e8116d8 and 6245682.

Files selected for processing (13)
  • .github/workflows/go.yml (1 hunks)
  • engine/atom.go (1 hunks)
  • engine/atom_test.go (2 hunks)
  • engine/builtin.go (12 hunks)
  • engine/builtin_test.go (38 hunks)
  • engine/compound.go (1 hunks)
  • engine/compound_test.go (2 hunks)
  • engine/parser.go (9 hunks)
  • engine/parser_test.go (2 hunks)
  • engine/term.go (3 hunks)
  • engine/text.go (7 hunks)
  • engine/text_test.go (3 hunks)
  • engine/vm.go (6 hunks)
Files skipped from review due to trivial changes (1)
  • .github/workflows/go.yml
Files skipped from review as they are similar to previous changes (3)
  • engine/builtin.go
  • engine/builtin_test.go
  • engine/text_test.go
Additional context used
GitHub Check: codecov/patch
engine/text.go

[warning] 286-286: engine/text.go#L286
Added line #L286 was not covered by tests


[warning] 293-293: engine/text.go#L293
Added line #L293 was not covered by tests

engine/parser.go

[warning] 300-300: engine/parser.go#L300
Added line #L300 was not covered by tests

Additional comments not posted (27)
engine/term.go (2)

61-66: LGTM! Proper initialization of _ops.

The getOps method ensures _ops is always initialized before use.


69-85: LGTM! Proper initialization of ordered map in defaultWriteOptions.

The ordered map in defaultWriteOptions is correctly initialized with the provided data.

engine/atom_test.go (1)

27-28: LGTM! Proper initialization of ordered map in test cases.

The test cases correctly initialize and use ordered maps.

engine/text.go (5)

31-38: LGTM! Proper usage of ordered map in Compile.

The Compile function correctly uses and initializes ordered maps for clauses.


81-81: LGTM! Proper initialization of ordered map in compile.

The compile function correctly initializes ordered maps for clauses.


223-223: LGTM! Proper initialization of ordered map in text struct.

The text struct correctly initializes ordered maps for clauses.


246-249: LGTM! Proper usage of ordered map in forEachUserDefined.

The forEachUserDefined method correctly uses ordered maps for clauses.


271-274: LGTM! Proper usage of ordered map in flush.

The flush method correctly uses ordered maps for clauses.

engine/compound_test.go (1)

Line range hint 17-53: LGTM! Proper initialization of ordered map in test cases.

The test cases correctly initialize and use ordered maps.

engine/vm.go (4)

6-6: Import of go-ordered-map library.

The import statement for the github.com/wk8/go-ordered-map/v2 package is correctly added.


Line range hint 55-64:
Updated VM struct fields.

The procedures field is now an ordered map and the operators field is updated to _operators.


154-154: Updated procedure retrieval in Arrive method.

The Arrive method now uses vm.getProcedure(pi) to retrieve procedures from the ordered map.


279-298: New methods for managing ordered maps.

The new methods getProcedure, setProcedure, and getOperators encapsulate the logic for accessing and modifying the ordered map.

engine/parser_test.go (1)

25-25: Initialization of operators field.

The operators field is now initialized using the newOperators function.

engine/atom.go (1)

244-244: Updated WriteTerm method.

The WriteTerm method now calls opts.getOps() to retrieve operators.

engine/compound.go (1)

48-52: Updated WriteCompound function.

The WriteCompound function now calls opts.getOps().Get(c.Functor()) to retrieve operators.

engine/parser.go (11)

6-6: Import of ordered map library is correct.

The addition of github.com/wk8/go-ordered-map/v2 is necessary for ordered map functionality.


25-25: Addition of _operators field is correct.

The _operators field is added to the Parser struct to store operators using an ordered map.


49-49: Initialization of _operators is correct.

The NewParser function initializes _operators using vm.getOperators(), ensuring the use of an ordered map for operators.


259-261: Addition of operators struct is correct.

The operators struct encapsulates the ordered map for managing operators.


263-265: Addition of newOperators function is correct.

The newOperators function initializes an operators instance with an ordered map.


268-269: Addition of defined method is correct.

The defined method checks if an operator is defined in the ordered map.


273-276: Addition of definedInClass method is correct.

The definedInClass method checks if an operator is defined in a specific class.


283-290: Addition of define method is correct.

The define method adds or updates an operator in the ordered map.


294-300: Addition of remove method is correct.

The remove method deletes an operator from the ordered map.

Tools
GitHub Check: codecov/patch

[warning] 300-300: engine/parser.go#L300
Added line #L300 was not covered by tests


343-348: Addition of getOperators method is correct.

The getOperators method returns the _operators field, initializing it if necessary.


425-426: Usage of getOperators method is correct.

The prefix, infix, and arg methods use getOperators to access operators, ensuring the use of the ordered map.

Also applies to: 440-441, 762-762

engine/text.go Show resolved Hide resolved
engine/text.go Show resolved Hide resolved
@bdeneux bdeneux force-pushed the feat/sorted-map-procedures branch from 6245682 to fbf751b Compare July 12, 2024 09:47
Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6245682 and fbf751b.

Files ignored due to path filters (1)
  • codecov.yml is excluded by !**/*.yml
Files selected for processing (1)
  • .github/workflows/go.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/go.yml

@bdeneux bdeneux requested review from ccamel and amimart July 12, 2024 10:08
Copy link
Member

@amimart amimart 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 to me, well done 👍

Copy link
Member

@ccamel ccamel left a comment

Choose a reason for hiding this comment

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

Lgtm

@bdeneux bdeneux force-pushed the feat/sorted-map-procedures branch from fbf751b to 3a315bf Compare July 18, 2024 11:18
@bdeneux bdeneux merged commit 21a231d into main Jul 18, 2024
1 check passed
@bdeneux bdeneux deleted the feat/sorted-map-procedures branch July 18, 2024 11:19
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