Browse Source

使用Map#computeIfAbsent

pull/2119/head
XenoAmess 3 years ago
parent
commit
0893198574
  1. 6
      src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java

6
src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java

@ -35,11 +35,7 @@ public class LongestMatchColumnWidthStyleStrategy extends AbstractColumnWidthSty
if (!needSetWidth) { if (!needSetWidth) {
return; return;
} }
Map<Integer, Integer> maxColumnWidthMap = cache.get(writeSheetHolder.getSheetNo()); Map<Integer, Integer> maxColumnWidthMap = cache.computeIfAbsent(writeSheetHolder.getSheetNo(), key -> new HashMap<>(16));
if (maxColumnWidthMap == null) {
maxColumnWidthMap = new HashMap<Integer, Integer>(16);
cache.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap);
}
Integer columnWidth = dataLength(cellDataList, cell, isHead); Integer columnWidth = dataLength(cellDataList, cell, isHead);
if (columnWidth < 0) { if (columnWidth < 0) {
return; return;

Loading…
Cancel
Save