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

Minor bug fix and performance Improvements #12

Merged
merged 1 commit into from
Apr 18, 2024
Merged

Minor bug fix and performance Improvements #12

merged 1 commit into from
Apr 18, 2024

Conversation

ciscorn
Copy link
Member

@ciscorn ciscorn commented Apr 18, 2024

Summary by CodeRabbit

  • New Features

    • Updated the polygon triangulation library to improve performance metrics across various polygon types.
  • Refactor

    • Enhanced data structures and methods within the library to optimize node management and triangulation processes.
  • Documentation

    • Updated README with new performance comparisons for the latest library version.
  • Chores

    • Updated package version to ensure compatibility and access to the latest features.

Copy link

coderabbitai bot commented Apr 18, 2024

Walkthrough

The update enhances the Rust port of the mapbox/earcut library for polygon triangulation. Changes include a minor version bump in a dependency, performance comparisons in the documentation, and significant code refactoring in the core library files. This includes structural adjustments to data representations and modifications to how nodes and their connections are managed and utilized within the library.

Changes

File(s) Change Summary
Cargo.toml Updated earcut package from 0.4.0 to 0.4.1.
README.md Updated performance metrics and comparisons for different polygon types across versions.
src/lib.rs Refactored Node struct, introduced LinkInfo struct, and updated methods for managing node relationships.

🐇✨
In the code garden, amidst the bits,
A tiny rabbit hops and sits.
With each commit, it leaps and twirls,
Weaving magic as the code unfurls.
Cheers to changes, small and big,
In our digital polygonal rig! 🎉🐰


Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e51bb5a and fdb82d5.
Files selected for processing (3)
  • Cargo.toml (1 hunks)
  • README.md (1 hunks)
  • src/lib.rs (28 hunks)
Files skipped from review due to trivial changes (1)
  • Cargo.toml
Additional Context Used
LanguageTool (98)
README.md (98)

Near line 1: Possible spelling mistake found.
Context: # earcut-rs [![Test](https://github.com/MIERUNE/ea...


Near line 3: Possible spelling mistake found.
Context: ...E/earcut-rs/actions/workflows/Test.yml) [![codecov](https://codecov.io/gh/MIERUNE/earcut-r...


Near line 7: Possible spelling mistake found.
Context: ....io/crates/earcut) A Rust port of the [mapbox/earcut](https://github.com/mapbox/earcu...


Near line 7: Possible spelling mistake found.
Context: ...tes/earcut) A Rust port of the mapbox/earcut poly...


Near line 7: Possible spelling mistake found.
Context: ...ed from scratch with some reference to [donbright/earcutr](https://github.com/donbright/e...


Near line 7: Possible spelling mistake found.
Context: ...ratch with some reference to donbright/earcutr....


Near line 9: Possible spelling mistake found.
Context: ...bright/earcutr). - Based on the latest earcut 2.2.4 release. - Designed to avoid unne...


Near line 11: Possible typo detected.
Context: ... - (Experimental) An additional module, utils3d, can rotate 3D coplanar polygons into ...


Near line 11: Possible spelling mistake found.
Context: ...tional module, utils3d, can rotate 3D coplanar polygons into the 2D plane before trian...


Near line 21: If the term is a proper noun, use initial capitals.
Context: ..." width="300">

## Benchmarks on Macbook Pro (M1 Pro) | Polygon | earcut.hpp ...


Near line 23: Possible typo: you repeated a whitespace
Context: ...arks on Macbook Pro (M1 Pro) | Polygon | earcut.hpp | earcut-rs (0.4.1) | ear...


Near line 23: Possible spelling mistake found.
Context: ...Macbook Pro (M1 Pro) | Polygon | earcut.hpp | earcut-rs (0.4.1) | earcutr (0....


Near line 23: Possible spelling mistake found.
Context: ... Pro (M1 Pro) | Polygon | earcut.hpp | earcut-rs (0.4.1) | earcutr (0.4.3)...


Near line 23: Possible typo: you repeated a whitespace
Context: ...o (M1 Pro) | Polygon | earcut.hpp | earcut-rs (0.4.1) | earcutr (0.4.3) | ...


Near line 23: Possible spelling mistake found.
Context: ... Pro) | Polygon | earcut.hpp | earcut-rs (0.4.1) | earcutr (0.4.3) | |----------...


Near line 23: Possible spelling mistake found.
Context: ... | earcut.hpp | earcut-rs (0.4.1) | earcutr (0.4.3) | |---------------|------------...


Near line 25: Possible typo: you repeated a whitespace
Context: ...---------:|----------------:| | bad_hole | 3.574 µs/i | 4.623 µs/i | ...


Near line 25: Possible typo: you repeated a whitespace
Context: ...--:|----------------:| | bad_hole | 3.574 µs/i | 4.623 µs/i | 4....


Near line 25: Possible spelling mistake found.
Context: ...-----------:| | bad_hole | 3.574 µs/i | 4.623 µs/i | 4.415 µs/i...


Near line 25: Possible typo: you repeated a whitespace
Context: ...-----:| | bad_hole | 3.574 µs/i | 4.623 µs/i | 4.415 µs/i | ...


Near line 25: Possible spelling mistake found.
Context: ...hole | 3.574 µs/i | 4.623 µs/i | 4.415 µs/i | | build...


Near line 25: Possible typo: you repeated a whitespace
Context: ... | 3.574 µs/i | 4.623 µs/i | 4.415 µs/i | | building |...


Near line 25: Possible spelling mistake found.
Context: ...4 µs/i | 4.623 µs/i | 4.415 µs/i | | building | 397...


Near line 26: Possible typo: you repeated a whitespace
Context: ...| 4.415 µs/i | | building | 397 ns/i | 195 ns/i | ...


Near line 26: Possible typo: you repeated a whitespace
Context: ...4.415 µs/i | | building | 397 ns/i | 195 ns/i | 60...


Near line 26: Possible spelling mistake found.
Context: ...i | | building | 397 ns/i | 195 ns/i | 604 ns/i...


Near line 26: Possible typo: you repeated a whitespace
Context: ... | building | 397 ns/i | 195 ns/i | 604 ns/i | | degenerat...


Near line 26: Possible spelling mistake found.
Context: ...ding | 397 ns/i | 195 ns/i | 604 ns/i | | degenerate |...


Near line 26: Possible typo: you repeated a whitespace
Context: ... | 397 ns/i | 195 ns/i | 604 ns/i | | degenerate | 142 ns/...


Near line 26: Possible spelling mistake found.
Context: ...7 ns/i | 195 ns/i | 604 ns/i | | degenerate | 142 ns/i | ...


Near line 27: Possible typo: you repeated a whitespace
Context: ...95 ns/i | 604 ns/i | | degenerate | 142 ns/i | 45 ns/i | ...


Near line 27: Possible typo: you repeated a whitespace
Context: .../i | 604 ns/i | | degenerate | 142 ns/i | 45 ns/i | 20...


Near line 27: Possible spelling mistake found.
Context: ... 604 ns/i | | degenerate | 142 ns/i | 45 ns/i | 206 ns/i...


Near line 27: Possible typo: you repeated a whitespace
Context: ... ns/i | | degenerate | 142 ns/i | 45 ns/i | 206 ns/i | | dude ...


Near line 27: Possible spelling mistake found.
Context: ...nerate | 142 ns/i | 45 ns/i | 206 ns/i | | dude |...


Near line 27: Possible typo: you repeated a whitespace
Context: ... | 142 ns/i | 45 ns/i | 206 ns/i | | dude | 5.061 µs/...


Near line 27: Possible spelling mistake found.
Context: ...2 ns/i | 45 ns/i | 206 ns/i | | dude | 5.061 µs/i | ...


Near line 28: Possible typo: you repeated a whitespace
Context: ... 45 ns/i | 206 ns/i | | dude | 5.061 µs/i | 6.496 µs/i | ...


Near line 28: Possible typo: you repeated a whitespace
Context: .../i | 206 ns/i | | dude | 5.061 µs/i | 6.496 µs/i | 8....


Near line 28: Possible spelling mistake found.
Context: ... 206 ns/i | | dude | 5.061 µs/i | 6.496 µs/i | 8.096 µs/i...


Near line 28: Possible typo: you repeated a whitespace
Context: ... ns/i | | dude | 5.061 µs/i | 6.496 µs/i | 8.096 µs/i | | empty_s...


Near line 28: Possible spelling mistake found.
Context: ... | 5.061 µs/i | 6.496 µs/i | 8.096 µs/i | | empty_square |...


Near line 28: Possible typo: you repeated a whitespace
Context: ... | 5.061 µs/i | 6.496 µs/i | 8.096 µs/i | | empty_square | 195 n...


Near line 28: Possible spelling mistake found.
Context: ...1 µs/i | 6.496 µs/i | 8.096 µs/i | | empty_square | 195 ns/i | ...


Near line 29: Possible typo: you repeated a whitespace
Context: ... µs/i | 8.096 µs/i | | empty_square | 195 ns/i | 74 ns/i | ...


Near line 29: Possible typo: you repeated a whitespace
Context: .../i | 8.096 µs/i | | empty_square | 195 ns/i | 74 ns/i | 33...


Near line 29: Possible spelling mistake found.
Context: ... 8.096 µs/i | | empty_square | 195 ns/i | 74 ns/i | 331 ns/i...


Near line 29: Possible typo: you repeated a whitespace
Context: ... µs/i | | empty_square | 195 ns/i | 74 ns/i | 331 ns/i | | water ...


Near line 29: Possible spelling mistake found.
Context: ...y_square | 195 ns/i | 74 ns/i | 331 ns/i | | water |...


Near line 29: Possible typo: you repeated a whitespace
Context: ...re | 195 ns/i | 74 ns/i | 331 ns/i | | water | 459.6 µs/...


Near line 29: Possible spelling mistake found.
Context: ...5 ns/i | 74 ns/i | 331 ns/i | | water | 459.6 µs/i | ...


Near line 30: Possible typo: you repeated a whitespace
Context: ... 74 ns/i | 331 ns/i | | water | 459.6 µs/i | 574.5 µs/i | ...


Near line 30: Possible typo: you repeated a whitespace
Context: .../i | 331 ns/i | | water | 459.6 µs/i | 574.5 µs/i | 80...


Near line 30: Possible spelling mistake found.
Context: ... 331 ns/i | | water | 459.6 µs/i | 574.5 µs/i | 801.3 µs/i...


Near line 30: Possible typo: you repeated a whitespace
Context: ... ns/i | | water | 459.6 µs/i | 574.5 µs/i | 801.3 µs/i | | water2 ...


Near line 30: Possible spelling mistake found.
Context: ...r | 459.6 µs/i | 574.5 µs/i | 801.3 µs/i | | water2 |...


Near line 30: Possible typo: you repeated a whitespace
Context: ... | 459.6 µs/i | 574.5 µs/i | 801.3 µs/i | | water2 | 334.1 µ...


Near line 30: Possible spelling mistake found.
Context: ...6 µs/i | 574.5 µs/i | 801.3 µs/i | | water2 | 334.1 µs/i | ...


Near line 31: Possible typo: you repeated a whitespace
Context: ... 574.5 µs/i | 801.3 µs/i | | water2 | 334.1 µs/i | 393.9 µs/i | ...


Near line 31: Possible typo: you repeated a whitespace
Context: .../i | 801.3 µs/i | | water2 | 334.1 µs/i | 393.9 µs/i | 45...


Near line 31: Possible spelling mistake found.
Context: ... 801.3 µs/i | | water2 | 334.1 µs/i | 393.9 µs/i | 450.3 µs/i...


Near line 31: Possible typo: you repeated a whitespace
Context: ... µs/i | | water2 | 334.1 µs/i | 393.9 µs/i | 450.3 µs/i | | water3 ...


Near line 31: Possible spelling mistake found.
Context: ...r2 | 334.1 µs/i | 393.9 µs/i | 450.3 µs/i | | water3 |...


Near line 31: Possible typo: you repeated a whitespace
Context: ... | 334.1 µs/i | 393.9 µs/i | 450.3 µs/i | | water3 | 13.12 µ...


Near line 31: Possible spelling mistake found.
Context: ...1 µs/i | 393.9 µs/i | 450.3 µs/i | | water3 | 13.12 µs/i | ...


Near line 32: Possible typo: you repeated a whitespace
Context: ... 393.9 µs/i | 450.3 µs/i | | water3 | 13.12 µs/i | 19.21 µs/i | ...


Near line 32: Possible typo: you repeated a whitespace
Context: .../i | 450.3 µs/i | | water3 | 13.12 µs/i | 19.21 µs/i | 23...


Near line 32: Possible spelling mistake found.
Context: ... 450.3 µs/i | | water3 | 13.12 µs/i | 19.21 µs/i | 23.46 µs/i...


Near line 32: Possible typo: you repeated a whitespace
Context: ... µs/i | | water3 | 13.12 µs/i | 19.21 µs/i | 23.46 µs/i | | water3b...


Near line 32: Possible spelling mistake found.
Context: ...r3 | 13.12 µs/i | 19.21 µs/i | 23.46 µs/i | | water3b |...


Near line 32: Possible typo: you repeated a whitespace
Context: ... | 13.12 µs/i | 19.21 µs/i | 23.46 µs/i | | water3b | 1.340 µ...


Near line 32: Possible spelling mistake found.
Context: ...2 µs/i | 19.21 µs/i | 23.46 µs/i | | water3b | 1.340 µs/i | ...


Near line 33: Possible typo detected.
Context: ... 19.21 µs/i | 23.46 µs/i | | water3b | 1.340 µs/i | 1.345 µs/...


Near line 33: Possible typo: you repeated a whitespace
Context: ...19.21 µs/i | 23.46 µs/i | | water3b | 1.340 µs/i | 1.345 µs/i | ...


Near line 33: Possible typo: you repeated a whitespace
Context: .../i | 23.46 µs/i | | water3b | 1.340 µs/i | 1.345 µs/i | 2....


Near line 33: Possible spelling mistake found.
Context: ... 23.46 µs/i | | water3b | 1.340 µs/i | 1.345 µs/i | 2.165 µs/i...


Near line 33: Possible typo: you repeated a whitespace
Context: ... µs/i | | water3b | 1.340 µs/i | 1.345 µs/i | 2.165 µs/i | | water4 ...


Near line 33: Possible spelling mistake found.
Context: ...r3b | 1.340 µs/i | 1.345 µs/i | 2.165 µs/i | | water4 |...


Near line 33: Possible typo: you repeated a whitespace
Context: ... | 1.340 µs/i | 1.345 µs/i | 2.165 µs/i | | water4 | 81.48 µ...


Near line 33: Possible spelling mistake found.
Context: ...0 µs/i | 1.345 µs/i | 2.165 µs/i | | water4 | 81.48 µs/i | ...


Near line 34: Possible typo: you repeated a whitespace
Context: ... 1.345 µs/i | 2.165 µs/i | | water4 | 81.48 µs/i | 110.6 µs/i | ...


Near line 34: Possible typo: you repeated a whitespace
Context: .../i | 2.165 µs/i | | water4 | 81.48 µs/i | 110.6 µs/i | 15...


Near line 34: Possible spelling mistake found.
Context: ... 2.165 µs/i | | water4 | 81.48 µs/i | 110.6 µs/i | 154.1 µs/i...


Near line 34: Possible typo: you repeated a whitespace
Context: ... µs/i | | water4 | 81.48 µs/i | 110.6 µs/i | 154.1 µs/i | | water_h...


Near line 34: Possible spelling mistake found.
Context: ...r4 | 81.48 µs/i | 110.6 µs/i | 154.1 µs/i | | water_huge |...


Near line 34: Possible typo: you repeated a whitespace
Context: ... | 81.48 µs/i | 110.6 µs/i | 154.1 µs/i | | water_huge | 6.906 m...


Near line 34: Possible spelling mistake found.
Context: ...8 µs/i | 110.6 µs/i | 154.1 µs/i | | water_huge | 6.906 ms/i | ...


Near line 35: Possible typo: you repeated a whitespace
Context: ....6 µs/i | 154.1 µs/i | | water_huge | 6.906 ms/i | 11.0k ms/i | ...


Near line 35: Possible typo: you repeated a whitespace
Context: .../i | 154.1 µs/i | | water_huge | 6.906 ms/i | 11.0k ms/i | 10...


Near line 35: Possible typo: you repeated a whitespace
Context: ... µs/i | | water_huge | 6.906 ms/i | 11.0k ms/i | 10.90 ms/i | | water_h...


Near line 35: Possible typo: you repeated a whitespace
Context: ... | 6.906 ms/i | 11.0k ms/i | 10.90 ms/i | | water_huge2 | 15.38 m...


Near line 36: Possible typo: you repeated a whitespace
Context: ...k ms/i | 10.90 ms/i | | water_huge2 | 15.38 ms/i | 23.60 ms/i | ...


Near line 36: Possible typo: you repeated a whitespace
Context: .../i | 10.90 ms/i | | water_huge2 | 15.38 ms/i | 23.60 ms/i | 22...


Near line 36: Possible typo: you repeated a whitespace
Context: ... ms/i | | water_huge2 | 15.38 ms/i | 23.60 ms/i | 22.35 ms/i | (Earcutr...


Near line 36: Possible typo: you repeated a whitespace
Context: ...2 | 15.38 ms/i | 23.60 ms/i | 22.35 ms/i | (Earcutr is not besed on t...


Near line 38: Possible spelling mistake found.
Context: ... 23.60 ms/i | 22.35 ms/i | (Earcutr is not besed on the latest earcut.)


Near line 38: Possible spelling mistake found.
Context: .../i | 22.35 ms/i | (Earcutr is not besed on the latest earcut.)


Near line 38: Possible spelling mistake found.
Context: ... | (Earcutr is not besed on the latest earcut.)

AST-based Instructions (5)
src/lib.rs (5)

[warning] 107-107: Found use of unsafe code. Unsafe code should be avoided whenever possible. Instead, prefer safe code and use unsafe code only when necessary.
Context: unsafe { NodeIndex::new_unchecked(1) }
Note: [CWE-242]: Use of Inherently Dangerous Function [REFERENCES]
- https://doc.rust-lang.org/std/keyword.unsafe.html


[warning] 108-108: Found use of unsafe code. Unsafe code should be avoided whenever possible. Instead, prefer safe code and use unsafe code only when necessary.
Context: unsafe { NodeIndex::new_unchecked(1) }
Note: [CWE-242]: Use of Inherently Dangerous Function [REFERENCES]
- https://doc.rust-lang.org/std/keyword.unsafe.html


[warning] 979-979: Found use of unsafe code. Unsafe code should be avoided whenever possible. Instead, prefer safe code and use unsafe code only when necessary.
Context: unsafe { NodeIndex::new_unchecked(nodes.len() as u32) }
Note: [CWE-242]: Use of Inherently Dangerous Function [REFERENCES]
- https://doc.rust-lang.org/std/keyword.unsafe.html


[warning] 980-980: Found use of unsafe code. Unsafe code should be avoided whenever possible. Instead, prefer safe code and use unsafe code only when necessary.
Context: unsafe { NodeIndex::new_unchecked(nodes.len() as u32 + 1) }
Note: [CWE-242]: Use of Inherently Dangerous Function [REFERENCES]
- https://doc.rust-lang.org/std/keyword.unsafe.html


[warning] 1012-1012: Found use of unsafe code. Unsafe code should be avoided whenever possible. Instead, prefer safe code and use unsafe code only when necessary.
Context: unsafe { NodeIndex::new_unchecked(nodes.len() as u32) }
Note: [CWE-242]: Use of Inherently Dangerous Function [REFERENCES]
- https://doc.rust-lang.org/std/keyword.unsafe.html

Additional comments not posted (4)
README.md (1)

23-36: Update the benchmark table to ensure accuracy and clarity.

The updated benchmark table provides a detailed comparison of processing times for various polygon types across different versions of the library. Ensure that all data is accurate and reflects the intended performance metrics.

src/lib.rs (3)

83-83: Refactor the Node struct to use a single array xy for coordinates.

This change simplifies the representation of coordinates and potentially enhances performance by reducing the complexity of node manipulation.


96-101: Introduce a new LinkInfo struct to encapsulate linking information between nodes.

This addition aids in maintaining clear and manageable node relationships, which is crucial for the integrity of the library's core functionalities.


131-131: Change the queue field in the Earcut struct to hold tuples of NodeIndex and a generic type T.

This modification enhances the flexibility and functionality of the queue management, aligning with the structural changes in the Node and Earcut structs.


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.

@ciscorn ciscorn merged commit 38c8e77 into main Apr 18, 2024
1 check passed
@ciscorn ciscorn deleted the imprv-0.4.1 branch April 18, 2024 08:36
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: 4

Actionable comments outside the diff hunks (3)
README.md (2)

Line range hint 15-15: Add alternative text to the image for accessibility.

- <img src="./docs/image.png" width="300">
+ <img src="./docs/image.png" alt="Sample triangulation result" width="300">

This change improves accessibility by providing a description of the image for screen readers.


Line range hint 18-18: Remove excessive blank lines to maintain a clean and professional appearance of the document.

- 
-
+ 
src/lib.rs (1)

Line range hint 979-980: Use of unsafe code in split_polygon method.

-    let a2_i = unsafe { NodeIndex::new_unchecked(nodes.len() as u32) };
-    let b2_i = unsafe { NodeIndex::new_unchecked(nodes.len() as u32 + 1) };
+    let a2_i = NodeIndex::new(nodes.len() as u32).expect("NodeIndex creation failed");
+    let b2_i = NodeIndex::new(nodes.len() as u32 + 1).expect("NodeIndex creation failed");

Replace unsafe code with safe alternatives to prevent potential runtime errors and enhance code safety.

| water3b | 1.340 µs/i | 1.345 µs/i | 2.165 µs/i |
| water4 | 81.48 µs/i | 110.6 µs/i | 154.1 µs/i |
| water_huge | 6.906 ms/i | 11.0k ms/i | 10.90 ms/i |
| water_huge2 | 15.38 ms/i | 23.60 ms/i | 22.35 ms/i |

(Earcutr is not besed on the latest earcut.)
Copy link

Choose a reason for hiding this comment

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

Correct the spelling error in the note about Earcutr.

- (Earcutr is not besed on the latest earcut.)
+ (Earcutr is not based on the latest earcut.)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
(Earcutr is not besed on the latest earcut.)
(Earcutr is not based on the latest earcut.)

| water_huge2 | 15.38 ms/i | 23.40 ms/i | 22.35 ms/i |
| Polygon | earcut.hpp | earcut-rs (0.4.1) | earcutr (0.4.3) |
|---------------|-------------:|------------------:|----------------:|
| bad_hole | 3.574 µs/i | 4.623 µs/i | 4.415 µs/i |
Copy link

Choose a reason for hiding this comment

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

Remove trailing spaces to clean up the document formatting.

- | bad_hole      |   3.574 µs/i |        4.623 µs/i |      4.415 µs/i |          
+ | bad_hole      |   3.574 µs/i |        4.623 µs/i |      4.415 µs/i |

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
| bad_hole | 3.574 µs/i | 4.623 µs/i | 4.415 µs/i |
| bad_hole | 3.574 µs/i | 4.623 µs/i | 4.415 µs/i |

Comment on lines +104 to +107
fn new(i: u32, xy: [T; 2]) -> Self {
Self {
i,
x,
y,
xy,
Copy link

Choose a reason for hiding this comment

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

Use of unsafe code in Node::new method.

-            prev_i: unsafe { NodeIndex::new_unchecked(1) },
-            next_i: unsafe { NodeIndex::new_unchecked(1) },
+            prev_i: NodeIndex::new(1).expect("NodeIndex creation failed"),
+            next_i: NodeIndex::new(1).expect("NodeIndex creation failed"),

Consider replacing unsafe code with safe alternatives wherever possible to enhance safety and maintainability.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
fn new(i: u32, xy: [T; 2]) -> Self {
Self {
i,
x,
y,
xy,
fn new(i: u32, xy: [T; 2]) -> Self {
Self {
i,
xy,
prev_i: NodeIndex::new(1).expect("NodeIndex creation failed"),
next_i: NodeIndex::new(1).expect("NodeIndex creation failed"),

last: Option<NodeIndex>,
) -> NodeIndex {
let mut p = Node::new(i, x, y);
let mut p = Node::new(i, xy);
Copy link

Choose a reason for hiding this comment

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

Use of unsafe code in insert_node method.

-    let p_i = unsafe { NodeIndex::new_unchecked(nodes.len() as u32) };
+    let p_i = NodeIndex::new(nodes.len() as u32).expect("NodeIndex creation failed");

It's recommended to use safe Rust practices by replacing unsafe code with safe alternatives to ensure robustness and prevent undefined behaviors.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
let mut p = Node::new(i, xy);
let p_i = NodeIndex::new(nodes.len() as u32).expect("NodeIndex creation failed");

@ciscorn ciscorn self-assigned this Oct 5, 2024
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.

1 participant