rorygraves / scalac_perf

The Scala programming language
http://www.scala-lang.org/
16 stars 3 forks source link

Regex inefficiencies #9

Closed mkeskells closed 6 years ago

mkeskells commented 7 years ago

regex code looks able to be improved

just be code inspection, looks to allocating temp data

benchmark & improve

ackratos commented 7 years ago

Could you please assign this to me?

ackratos commented 7 years ago

Hi @rorygraves I have no idea on how to optimize this piece of code:

Some((1 to m.groupCount).toList map m.group)

Could you please give me some suggestions?

ackratos commented 7 years ago

https://github.com/scala/scala/pull/6048

ackratos commented 7 years ago

some ideas from @mkeskells

Some((1 to m.groupCount).toList map m.group)

Could be changed to:

var result = List.empty(...)
var count = m.groupCount
while (count > 0) {
  result =  m.group(count) :: result
  count -= 1
} 

or

@tailrec a def for above code could be better

or

Some((1 to m.groupCount).map(m.group)(breakOut))
mkeskells commented 7 years ago

@ackratos can you share the benchmark & branch

ackratos commented 7 years ago

@mkeskells i pasted the branch above https://github.com/scala/scala/pull/6048 haven't pushed micro benchmark.

ackratos commented 6 years ago

resolved at https://github.com/scala/scala/pull/6048

rorygraves commented 6 years ago

Great stuff

On 23 Sep 2017, at 10:30, cong notifications@github.com wrote:

resolved at scala#6048

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.