Skip to content

Commit 42df693

Browse files
authored
Polish empty check. (#3977)
Signed-off-by: Mengqi Xu <[email protected]>
1 parent 1c2fc16 commit 42df693

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

spring-ai-model/src/main/java/org/springframework/ai/support/UsageCalculator.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,7 @@ public static Usage getCumulativeUsage(final Usage currentUsage, final ChatRespo
7272
* @return the boolean value to represent if it is empty.
7373
*/
7474
public static boolean isEmpty(Usage usage) {
75-
if (usage == null) {
76-
return true;
77-
}
78-
else if (usage != null && usage.getTotalTokens() == 0L) {
79-
return true;
80-
}
81-
return false;
75+
return usage == null || usage.getTotalTokens() == 0L;
8276
}
8377

8478
}

0 commit comments

Comments
 (0)