Skip to content

Fix two Swift profiling bugs#3954

Merged
parrt merged 2 commits intoantlr:devfrom
nesevis:fix/swift-profiling-bugs
Nov 19, 2022
Merged

Fix two Swift profiling bugs#3954
parrt merged 2 commits intoantlr:devfrom
nesevis:fix/swift-profiling-bugs

Conversation

@nesevis
Copy link
Contributor

@nesevis nesevis commented Nov 9, 2022

This PR fixes:

  • A hard crash in the ProfilingATNSimulator initialiser, from attempting to set values via subscript on an empty array.
  • A bug in ProfilingATNSimulator.adaptivePredict's method that meant .timeInPrediction would always report zero; this has now replaced by the preferred way to measure time in Swift.

The initialiser creates an empty array. This means that indexed subscripts will be out of range.

The Swift compiler amortises `.append` to effectively O(1).

Signed-off-by: Chris Kolbu <chris.kolbu@ittybittyapps.com>
The current implementation using date object did not actually work (e.g the `timeInPrediction` was always zero). This has now been replaced by the preferred way to measure time in Swift.

See discussion: https://forums.swift.org/t/recommended-way-to-measure-time-in-swift/33326

Signed-off-by: Chris Kolbu <chris.kolbu@ittybittyapps.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants