This and the next one are inside of the loop so there is no benefit.
And I think encode does exactly the same check inside so I'd just drop this "optimization". 
The only thing I can see that may go wrong is DMD not inlining again.