Re: HashMap.putAll can cause redundant space waste

2022-02-10 Thread Xeno Amess
problem is that need adding some public api to HashMap or Collections. Yep, sounds like a better version of guava.newHashMap. Xeno Amess 于2022年2月9日周三 09:51写道: > I agree that it would >> be preferable for the expression to be something like this: > > (int) Math.ceil(expected / 0.

Re: HashMap.putAll can cause redundant space waste

2022-02-08 Thread Xeno Amess
but it's confusing that its behavior differs from HashMap > in this > regard.) > > If we don't add a Java SE utility like "newHashMapWithExpectedSize", > fallbacks would > be to introduce an internal JDK utility method that is called from various > places, > or jus

Re: HashMap.putAll can cause redundant space waste

2022-02-04 Thread Xeno Amess
wait, things get interesting now. We do have such a test named ConstantDirectoryOptimalCapacity to make sure this does not happen, but my tests still fill under the idea debugger. Is there any specialist for help? I would dig in but it is a little complicated. [image: image.png] Xeno Amess 于2022

Re: HashMap.putAll can cause redundant space waste

2022-02-04 Thread Xeno Amess
Sorry for my mistake. After a more throughout dig in, this thing has already fixed several years ago, at year 2015. Issue close. Xeno Amess 于2022年2月4日周五 21:40写道: > Besides, is it worthy to develop a public float Math.ceil(float) function? > > Xeno Amess 于2022年2月4日周五 21:39写道: > >

Re: HashMap.putAll can cause redundant space waste

2022-02-04 Thread Xeno Amess
Besides, is it worthy to develop a public float Math.ceil(float) function? Xeno Amess 于2022年2月4日周五 21:39写道: > patch applied. > > Index: src/java.base/share/classes/java/lang/Module.java > IDEA additional info: > Subsystem: com.intellij.openapi.diff.impl.patch.Chars

Re: HashMap.putAll can cause redundant space waste

2022-02-04 Thread Xeno Amess
this(Math.max((int) ((float)m.size() / DEFAULT_LOAD_FACTOR + 1.0F), +this(Math.max((int) Math.ceil(m.size() / DEFAULT_LOAD_FACTOR), DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR); putAll(m); Xeno Amess 于2022年2月4日周五 18:45写道: > also find some other places ha

Re: HashMap.putAll can cause redundant space waste

2022-02-04 Thread Xeno Amess
also find some other places have same problem. If some of your already-in people aggree, I would create a pr, but according to the rules seems I should wait for now. Xeno Amess 于2022年2月4日周五 18:42写道: > import java.lang.reflect.Array; > import java.lang.reflect.Field; > import java.uti

HashMap.putAll can cause redundant space waste

2022-02-04 Thread Xeno Amess
import java.lang.reflect.Array; import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; public class TestMap { public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException { HashMap a = new HashMap<>(); fill12(a);

Re: a quick question about String

2021-12-24 Thread Xeno Amess
gree. Pooling takes time and > memory > >> to manage, and if there are very few duplicates, it's a waste of both. I > >> believe it should be up to the programmer to decide if this is > appropriate > >> in their situation. Of course, the GC system seems to be capable

Re: a quick question about String

2021-12-23 Thread Xeno Amess
never should,as Object can be use as lock. XenoAmess From: core-libs-dev on behalf of Bernd Eckenfels Sent: Friday, December 24, 2021 5:51:55 AM To: alan Snyder ; core-libs-dev Subject: Re: a quick question about String new String() always creates a new

Re: Will it be worthy to add some public static final empty arrays for some most used types in some place in java.base, other than create them multi times in several places?

2021-10-09 Thread Xeno Amess
sample codes here https://github.com/openjdk/jdk/pull/5874 if anyone interested Xeno Amess 于2021年10月10日周日 上午4:00写道: > sigh. > > quite some good things I always want are at valhalla > <https://openjdk.java.net/projects/valhalla/>, but I just don't think > they will come sta

Re: Will it be worthy to add some public static final empty arrays for some most used types in some place in java.base, other than create them multi times in several places?

2021-10-09 Thread Xeno Amess
projects/valhalla/ > [2] https://openjdk.java.net/jeps/8261007 > > -Pavel > > > On 9 Oct 2021, at 18:19, Xeno Amess wrote: > > > > I suggest putting them in Arrays btw. > >

Will it be worthy to add some public static final empty arrays for some most used types in some place in java.base, other than create them multi times in several places?

2021-10-09 Thread Xeno Amess
I suggest putting them in Arrays btw.

Re: ideas about making static shared pool for skip buffers for InputStream and Reader

2021-10-07 Thread Xeno Amess
Brian Burkhalter 于2021年10月8日周五 上午5:37写道: > Re-directing to the appropriate mailing list, core-libs-dev; please > exclude jdk-dev from any reply. > > How can they be shared when they are different data types, viz., byte vs. > char? > > On Oct 7, 2021, at 2:26 PM, Xeno Amess wro

Re: ideas about making static shared pool for skip buffers for InputStream and Reader

2021-10-07 Thread Xeno Amess
Xeno Amess 于 2021年10月8日周五 上午5:45写道: > each for each class... > > byte[] and char[] of course cannot mix...at least, cannt mix from java > side. I'm not that sure if such black magic can do on jvm side. I don't > think it can. > > It is not safe to open the containing pool to