From 0ff3343282b1f48bddf8ffaf0ff8e8993c395c01 Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Mon, 25 Feb 2013 13:33:47 -0500 Subject: [PATCH] Addressing Eric's comments -- added @param docs to the new variables -- made all variables final -- switched to string builder instead of String for performance. GSATDG-83 --- .../compression/reducereads/ReduceReads.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/ReduceReads.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/ReduceReads.java index 7f39452c4..e89158412 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/ReduceReads.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/ReduceReads.java @@ -626,21 +626,27 @@ public class ReduceReads extends ReadWalker, Redu * Compresses the read name using the readNameHash if we have already compressed * this read name before. * - * @param read any read + * @param hash the hash table containing the read name to compressed read name map + * @param read any read + * @param nextReadNumber the number to use in the compressed read name in case this is a new read name + * @return the next number to use in the compressed read name */ - protected static long compressReadName(Object2LongOpenHashMap hash, GATKSAMRecord read, long nextReadNumber) { + protected static long compressReadName(final Object2LongOpenHashMap hash, final GATKSAMRecord read, final long nextReadNumber) { final String name = read.getReadName(); + final StringBuilder compressedName = new StringBuilder(); long result = nextReadNumber; - String compressedName = read.isReducedRead() ? "C" : ""; + if (read.isReducedRead()) { + compressedName.append("C"); + } final Long readNumber = hash.get(name); if (readNumber != null) { - compressedName += readNumber.toString(); + compressedName.append(readNumber); } else { hash.put(name, nextReadNumber); - compressedName += "" + nextReadNumber; + compressedName.append(nextReadNumber); result++; } - read.setReadName(compressedName); + read.setReadName(compressedName.toString()); return result; }