It looks like this sequentially writes back each codebase to the state object that you just extracted it from.  I don't see why there's a need to write that state back at all, let alone one codebase at a time.