Skip to content

ref: simplify node occurrence check in validationImpossibleOneway#11943

Open
dipanshurdev wants to merge 1 commit intoopenstreetmap:developfrom
dipanshurdev:dev02
Open

ref: simplify node occurrence check in validationImpossibleOneway#11943
dipanshurdev wants to merge 1 commit intoopenstreetmap:developfrom
dipanshurdev:dev02

Conversation

@dipanshurdev
Copy link

Description

Optimize node occurrence detection in impossible oneway validation

Improves code efficiency and readability by replacing a manual loop
with native Array methods. The function now uses indexOf/lastIndexOf
comparison to detect duplicate nodes in a way.

Type of Change

  • Performance optimization
  • Code quality improvement
  • Bug fix
  • New feature

Changes

  • Replaced manual loop iteration with indexOf() and lastIndexOf() comparison
  • Reduced from 7 lines to 1 line
  • More idiomatic JavaScript using native array methods
  • No behavioral changes - same validation logic

Performance Impact

  • Single algorithm pass instead of iterating array
  • Leverages optimized native browser/runtime methods
  • Reduces memory allocation (no counter variable)

Testing

  • No functional changes - same validation behavior
  • Detects duplicate nodes the same way
  • Code is clearer and more maintainable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant