Skip to content

Commit

Permalink
Optimize entry size when the singleton weigher is used
Browse files Browse the repository at this point in the history
In this case the cache acts the same as maximumSize, but the caller
constructed using maximumWeight + weigher. The per-entry weight field
is not needed, so the maximumSize's entry should be used instead. This
allows optimizing when configured like in [1].

[1] https://gerrit-review.googlesource.com/c/gerrit/+/244612
  • Loading branch information
ben-manes committed Nov 9, 2019
1 parent eda7b10 commit 37f6ad3
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ private NodeSelectorCode maximum() {
block
.beginControlFlow("if (builder.evicts())")
.addStatement("sb.append('M')")
.beginControlFlow("if ((isAsync && builder.evicts()) || builder.isWeighted())")
.beginControlFlow("if (isAsync "
+ "|| (builder.isWeighted() && (builder.weigher != Weigher.singletonWeigher())))")
.addStatement("sb.append('W')")
.nextControlFlow("else")
.addStatement("sb.append('S')")
Expand Down

0 comments on commit 37f6ad3

Please sign in to comment.