beyondgrep / ack2

**ack 2 is no longer being maintained. ack 3 is the latest version.**
https://github.com/beyondgrep/ack3/
Other
1.48k stars 140 forks source link

Reduce unnessecary big regexps #521

Closed pengi closed 9 years ago

pengi commented 9 years ago

Since the regular expression should contain [pt]+, means that there might be an arbitrary number of t:s at the end. The following t+ means the regexp should end with a t. Removing the + means the t:s prior is just contained in the [pt]+

This reduces the file size with 1 byte, which, even though it's really unlikely, means having space for this app or not.

THPPPTPTPTPTPPTT!

hoelzro commented 9 years ago

This looks fine to me, but I think @petdance wants to go over pending changes for 2.16 before we merge any more pull requests. Then again, this might be small enough that it's ok; I'll wait for him to weigh in.

petdance commented 9 years ago

I appreciate the pull request, but I don't want to make a change for change's sake. I'm not going to merge this.

Also, less important, the change you made changes it so that thpppptptpttp is valid, and that was not my intent.

pengi commented 9 years ago

D'oh...

But it still is a t at the end, which means that it needs to end with t, so thppptptptptp isn't valid, since it doesn't match the "t$" part

it's just that the old one is ambigous in the sense that thppttt should match (th)(pp)(ttt) or (th)(ppt)(tt) or (th)(pptt)(t) in the /^th[pt]+t+$/ regexp, divided in the three parts th, [pt]+ and t+

(This pull request wasn't that serious, we were just looking for easter eggs in projects and stumbled upon this. great work with ack btw.) :D