Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Collections.emptyList()和new ArrayList()之间的GWT是否存在差异_Gwt - Fatal编程技术网

Collections.emptyList()和new ArrayList()之间的GWT是否存在差异

Collections.emptyList()和new ArrayList()之间的GWT是否存在差异,gwt,Gwt,众所周知,在Java中,返回Collections.emptyList而不是空ArrayList对象是一种很好的做法。在为GWT编写代码时,GWT编译器如何处理此空列表?它与ArrayList一样有效还是毫无意义?集合。空列表()可能比新ArrayList()(与相比)更好,但我相信它实际上并不重要(ArrayList可能无论如何都会被使用,它是在小部件中内部使用的,因此如果使用Collections.emptyList(),它将不会被优化掉,emptyList太小了,不值得对它进行优化;同样,

众所周知,在Java中,返回Collections.emptyList而不是空ArrayList对象是一种很好的做法。在为GWT编写代码时,GWT编译器如何处理此空列表?它与ArrayList一样有效还是毫无意义?

集合。空列表()
可能比
新ArrayList()
(与相比)更好,但我相信它实际上并不重要(
ArrayList
可能无论如何都会被使用,它是在小部件中内部使用的,因此如果使用
Collections.emptyList()
,它将不会被优化掉,
emptyList
太小了,不值得对它进行优化;同样,它也可能被您没有编写的代码使用,所以…)

根据经验,除非你有一个性能/代码大小问题需要解决,否则你不应该关心微优化。“是万恶之源”(Donald Knuth)