HDFS-9350. Avoid creating temprorary strings in Block.toString() and getBlockName() (Staffan Friberg via cmccabe)

This commit is contained in:
Colin Patrick Mccabe 2015-12-18 09:40:39 -08:00
parent f349d0a76c
commit e63388fdf2
2 changed files with 8 additions and 2 deletions

View File

@ -132,7 +132,8 @@ public void setBlockId(long bid) {
/** /**
*/ */
public String getBlockName() { public String getBlockName() {
return BLOCK_FILE_PREFIX + String.valueOf(blockId); return new StringBuilder().append(BLOCK_FILE_PREFIX)
.append(blockId).toString();
} }
/** /**
@ -160,7 +161,9 @@ public void setGenerationStamp(long stamp) {
* @return the string representation of the block * @return the string representation of the block
*/ */
public static String toString(final Block b) { public static String toString(final Block b) {
return b.getBlockName() + "_" + b.getGenerationStamp(); StringBuilder sb = new StringBuilder();
b.appendStringTo(sb);
return sb.toString();
} }
/** /**

View File

@ -910,6 +910,9 @@ Release 2.9.0 - UNRELEASED
HDFS-8477. describe dfs.ha.zkfc.port in hdfs-default.xml. HDFS-8477. describe dfs.ha.zkfc.port in hdfs-default.xml.
(Kanaka Kumar Avvaru via wang) (Kanaka Kumar Avvaru via wang)
HDFS-9350. Avoid creating temprorary strings in Block.toString() and
getBlockName() (Staffan Friberg via cmccabe)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES