From 0893198574d29bfb0fa2fb47077137373d8c4320 Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Tue, 5 Oct 2021 12:38:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8Map#computeIfAbsent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../style/column/LongestMatchColumnWidthStyleStrategy.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java b/src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java index d248de13..ee47fbfb 100644 --- a/src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java +++ b/src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java @@ -35,11 +35,7 @@ public class LongestMatchColumnWidthStyleStrategy extends AbstractColumnWidthSty if (!needSetWidth) { return; } - Map maxColumnWidthMap = cache.get(writeSheetHolder.getSheetNo()); - if (maxColumnWidthMap == null) { - maxColumnWidthMap = new HashMap(16); - cache.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap); - } + Map maxColumnWidthMap = cache.computeIfAbsent(writeSheetHolder.getSheetNo(), key -> new HashMap<>(16)); Integer columnWidth = dataLength(cellDataList, cell, isHead); if (columnWidth < 0) { return;