多数のレコードを繰り返し処理し、それらのレコードのデータに基づいて状態情報を設定している状況にあります。このようなもの(実際のコードではなく、単純化したもの):
StateObject state;
ConcurrentQueue<Record> records;
while(!records.IsEmpty())
{
//set state here based on the next record
}
したがって、より効率的/より良い練習になるでしょうか
{
//set state here based on the next record
Record r = records.next();
state = r.state;
}
また
{
//set state here based on the next record
Record r = records.next();
if(state != r.state)
state = r.state;
}