我正在使用菱形运算符来启动列表中的对象.但是,随着数组对象数量的增加,编译时间从几秒增加到几小时.我的eclipse自动构建使我的eclipse无响应.然后我注意到这是一个javac问题.当我更换所有<>与<String, List<Category>>编译时间追溯到短短的几秒钟.这是我做错了还是只是Java性能问题?
这是我的代码,需要花费Java小时来编译(或崩溃javac v8u25):
List<Pair<String, List<Category>>> categoryMappings = null;
public void reloadStaticData() {
// Left one is the provider's category and right one is ours
try(UoW luow = CoreModule.getInstance(UoW.class)) {
CategoryRepo categoryRepo = luow.getCategoryRepo();
categoryMappings = Arrays.asList(
// Nightlife
new ImmutablePair<>("Bars", Arrays.asList(categoryRepo.findByName("Bar & Pubs").get())),
new ImmutablePair<>("Ski-Bar", Arrays.asList(categoryRepo.findByName("Bar & Pubs").get())),
new ImmutablePair<>("Bar", Arrays.asList(categoryRepo.findByName("Bar & Pubs").get())),
new ImmutablePair<>("Beer", Arrays.asList(categoryRepo.findByName("Bar & Pubs").get())),
new ImmutablePair<>("Pubs", Arrays.asList(categoryRepo.findByName("Bar & Pubs").get())),
new ImmutablePair<>("Clubs", Arrays.asList(categoryRepo.findByName("Bar & Pubs").get())),
new ImmutablePair<>("Dance", Arrays.asList(categoryRepo.findByName("Bar & Pubs").get()
,categoryRepo.findByName("Clubs").get())),
// …Run Code Online (Sandbox Code Playgroud) 我正在使用一个提供列表的静态类的多线程应用程序.我希望静态类的getter能够自由地工作(彼此不同步)但是当setter工作时我希望所有的getter都被锁定并等到setter的工作完成.我不想在调用它们时锁定getter,因为它会大大降低性能.吸毒者每天被叫1,000,000次,而且每天只能使用一次.
我在javascript中使用了html字符串并使用正则表达式我想删除html标签中的id,style和class属性,例如我有:
New York City.<div style="padding:20px" id="upp" class="upper"><div style="background:#F2F2F2; color:black; font-size:90%; padding:10px 10px; width:500px;">This message is.</div></div>
Run Code Online (Sandbox Code Playgroud)
我希望这个String成为:
New York City.<div><div>This message is.</div></div>
Run Code Online (Sandbox Code Playgroud) 目前我只使用这两个替换来显示我从DB获得的消息:
text = text.replace("\r\n", "<br />");
text = text.replace("\n", "<br />");
Run Code Online (Sandbox Code Playgroud)
但问题是,如果有很多连续的"\n",我会有很多
s或空格,我只想把它们全部一个.那你的建议是什么?是否有快速替换方法使所有连续的\n \n \n \n \n \n \n只有一个br?