Source:
<code>public PatchSetAttribute asPatchSetAttribute(final PatchSet patchSet) { PatchSetAttribute p = new PatchSetAttribute(); p.revision = patchSet.getRevision().get(); p.number = Integer.toString(patchSet.getPatchSetId()); p.ref = patchSet.getRefName(); p.uploader = asAccountAttribute(patchSet.getUploader()); p.createdOn = patchSet.getCreatedOn().getTime() / 1000L; final PatchSet.Id pId = patchSet.getId(); try { final ReviewDb db = schema.open(); try { p.parents = new ArrayList<String>(); for (PatchSetAncestor a : db.patchSetAncestors().ancestorsOf( patchSet.getId())) { p.parents.add(a.getAncestorRevision().get()); } Account.Id authorId = psInfoFactory.get(db, pId).getAuthor().getAccount(); if (authorId == null) { p.author = new AccountAttribute(); <START> p.author.email = psInfoFactory.get(db, pId).getAuthor().getEmail(); <END> p.author.name = psInfoFactory.get(db, pId).getAuthor().getName(); p.author.username = ""; } else { p.author = asAccountAttribute(authorId); } Change change = db.changes().get(pId.getParentKey()); List<Patch> list = patchListCache.get(change, patchSet).toPatchList(pId); for (Patch pe : list) { if (!Patch.COMMIT_MSG.equals(pe.getFileName())) { p.sizeDeletions -= pe.getDeletions(); p.sizeInsertions += pe.getInsertions(); } } } finally { db.close(); } } catch (OrmException e) { log.error("Cannot load patch set data for " + patchSet.getId(), e); } catch (PatchSetInfoNotAvailableException e) { log.error(String.format("Cannot get authorEmail for %s.", pId), e); } catch (PatchListNotAvailableException e) { log.error(String.format("Cannot get size information for %s.", pId), e); } return p; }</code><technical_language>factor out psInfoFactory.get(db, pId).getAuthor() a variable? I in 3 places now</technical_language>

Target:
public PatchSetAttribute asPatchSetAttribute(final PatchSet patchSet) { PatchSetAttribute p = new PatchSetAttribute(); p.revision = patchSet.getRevision().get(); p.number = Integer.toString(patchSet.getPatchSetId()); p.ref = patchSet.getRefName(); p.uploader = asAccountAttribute(patchSet.getUploader()); p.createdOn = patchSet.getCreatedOn().getTime() / 1000L; final PatchSet.Id pId = patchSet.getId(); try { final ReviewDb db = schema.open(); try { p.parents = new ArrayList<String>(); for (PatchSetAncestor a : db.patchSetAncestors().ancestorsOf( patchSet.getId())) { p.parents.add(a.getAncestorRevision().get()); } UserIdentity author = psInfoFactory.get(db, pId).getAuthor(); if (author.getAccount() == null) { p.author = new AccountAttribute(); p.author.email = author.getEmail(); p.author.name = author.getName(); p.author.username = ""; } else { p.author = asAccountAttribute(author.getAccount()); } Change change = db.changes().get(pId.getParentKey()); List<Patch> list = patchListCache.get(change, patchSet).toPatchList(pId); for (Patch pe : list) { if (!Patch.COMMIT_MSG.equals(pe.getFileName())) { p.sizeDeletions -= pe.getDeletions(); p.sizeInsertions += pe.getInsertions(); } } } finally { db.close(); } } catch (OrmException e) { log.error("Cannot load patch set data for " + patchSet.getId(), e); } catch (PatchSetInfoNotAvailableException e) { log.error(String.format("Cannot get authorEmail for %s.", pId), e); } catch (PatchListNotAvailableException e) { log.error(String.format("Cannot get size information for %s.", pId), e); } return p; }