Skip to content

Commit

Permalink
[MODIFY] optimize ListNullcheck
Browse files Browse the repository at this point in the history
- List null 일 경우 loop execute 를 skip 합니다.
  • Loading branch information
himodu committed May 14, 2024
1 parent 1bf3c85 commit deb4241
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ public AllBooth getAllbooth(String userHash) {
.build());
}

for(UserBoothEntity userBooth : userBoothEntityList){
Booth tempbooth = boothDtos.get(userBooth.getBooth().getId().intValue()-1);
tempbooth.setLikable(false);
boothDtos.set(userBooth.getBooth().getId().intValue()-1, tempbooth);
if(!userBoothEntityList.isEmpty()){
for(UserBoothEntity userBooth : userBoothEntityList){
Booth tempbooth = boothDtos.get(userBooth.getBooth().getId().intValue()-1);
tempbooth.setLikable(false);
boothDtos.set(userBooth.getBooth().getId().intValue()-1, tempbooth);
}
}


return AllBooth.builder()
.count(boothDtos.size())
.boothDtoes(boothDtos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ public List<Comment> getCommentPage(Long boothId, int perpage, int page, String
}else{
comments = commentRepository.findAllOrderById(booth.getId(), perpage, offset);
}
for(CommentEntity c: comments){
Comment comment = c.toDto();
if(c.getUser().getUserHash().equals(userHash)){
comment.setDeleteable(true);
}else{
comment.setDeleteable(false);

if(!comments.isEmpty()) {
for (CommentEntity c : comments) {
Comment comment = c.toDto();
if (c.getUser().getUserHash().equals(userHash)) {
comment.setDeleteable(true);
} else {
comment.setDeleteable(false);
}
result.add(comment);
}
result.add(comment);
}
return result;

Expand Down

0 comments on commit deb4241

Please sign in to comment.