CC: | rabbit [...] rabbit.us |
Subject: | Optimize generated constructor by avoiding NEXTSTATE |
I was looking at a generated constructor in NYTProf: https://annotate.driftt.com/view?i=b7b9a7gqxeh6xgx%2F2015-07-15_at_10.23_AM.png%2F
Discussing it with ribasushi, he told me that he optimized this sort of thing in the DBIC rowparser by using "," instead of ";" to avoid the NEXTSTATE ops. The commit for it indicates a noticeable speed improvement: https://github.com/dbsrgits/dbix-class/commit/05a5ca4b9
He suggested that the generated assignment could be better expressed along these lines:
( exists $args{foo} and $new->{foo} = $args->{foo} ), ( ... ), ( ... ), ...
While ugly, it's generated code anyway and probably worth it for the speed improvement.