raftLog: enhance check in compact

@xiangli-cmu @bmizerany 
Can you define lastIndex and lastTerm as the same variables at the top. It took me a second to wrap my mind around this.