From 26734536f7be53647643a5d9845a5caee77cc1ff Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Mon, 30 Dec 2024 20:33:10 -0800 Subject: [PATCH] ICU-22991 Reduce fStamp to 8 bits Reduce 24x3=72 bytes per Calendar object by changing from 32 bits integer to 8 bits integer for the stamp array. --- icu4c/source/i18n/calendar.cpp | 18 ++++++------------ icu4c/source/i18n/unicode/calendar.h | 6 +++--- .../main/java/com/ibm/icu/util/Calendar.java | 14 +++++++------- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index ca3de520c8f2..a1d80af5f011 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -156,7 +156,7 @@ U_CFUNC void ucal_dump(UCalendar* cal) { #endif /* Max value for stamp allowable before recalculation */ -#define STAMP_MAX 10000 +#define STAMP_MAX 127 static const char * const gCalTypes[] = { "gregorian", @@ -1166,12 +1166,8 @@ Calendar::setTimeInMillis( double millis, UErrorCode& status ) { fAreFieldsSet = fAreAllFieldsSet = false; fIsTimeSet = fAreFieldsVirtuallySet = true; - for (int32_t i=0; istamp[], an internal array. * @serial */ - private transient int nextStamp = MINIMUM_USER_STAMP; + private transient byte nextStamp = MINIMUM_USER_STAMP; /* Max value for stamp allowable before recalculation */ - private static int STAMP_MAX = 10000; + private static byte STAMP_MAX = Byte.MAX_VALUE; // the internal serial version which says which version was written // - 0 (default) for version up to JDK 1.1.5 @@ -1684,7 +1684,7 @@ private void setCalendarLocale(ULocale locale) { private void recalculateStamp() { int index; - int currentValue; + byte currentValue; int j, i; nextStamp = 1; @@ -1721,7 +1721,7 @@ private void initInternal() throw new IllegalStateException("Invalid fields[]"); } ///CLOVER:ON - stamp = new int[fields.length]; + stamp = new byte[fields.length]; int mask = (1 << ERA) | (1 << YEAR) | (1 << MONTH) | @@ -4904,7 +4904,7 @@ public Object clone() Calendar other = (Calendar) super.clone(); other.fields = new int[fields.length]; - other.stamp = new int[fields.length]; + other.stamp = new byte[fields.length]; System.arraycopy(this.fields, 0, other.fields, 0, fields.length); System.arraycopy(this.stamp, 0, other.stamp, 0, fields.length);