The author actually touches on why it couldn't optimise this away: .* doesn't match any character sequence, it is equivalent to [^\n]* by default
Also, assuming RE2 works like other engines, it also couldn't convert to a partial match without the .* prefix+suffix even if .* matched any char, because you might then ask for capture group 0
This is something the compiler should do for me.