Skip to content

Conversation

@kripken
Copy link
Member

@kripken kripken commented Oct 22, 2025

Avoids deep recursion on long names.

Fixes #7981

@kripken kripken requested a review from tlively October 22, 2025 19:28
@kripken kripken changed the title Un-recurse wildcard matching Un-recurse wildcard matching [NFC] Oct 22, 2025
Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

Pushing two tasks at each step, one that still has the wildcard and another that doesn't, seems overly complicated and expensive.

  1. I would expect us only to push data onto the stack at necessary branch points in the search, not at every character.
  2. If we encounter a mismatch, we should just pop the stack to backtrack (or return false if the stack is empty). There should be no need for a separate results vector.

@kripken
Copy link
Member Author

kripken commented Oct 22, 2025

The push at the end of the loop is redundant with the pop, but to save that work would make the code more complex. And this is not performance-sensitive code.

Otherwise I don't quite follow your suggestions?

@tlively
Copy link
Member

tlively commented Oct 23, 2025

To illustrate what I mean (and to procrastinate on working on various slide decks) I went ahead and implemented what I had in mind: #7988. I'm happy to go with whichever approach seems simpler, though. (Maybe a hybrid approach would be simplest.)

@kripken
Copy link
Member Author

kripken commented Oct 23, 2025

Closing in favor of the other PR.

@kripken kripken closed this Oct 23, 2025
@kripken kripken deleted the unrec branch October 23, 2025 15:37
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.

Segfault / Stackoverflow when binaryen tries to match a pattern on names

2 participants