HappenLee commented on code in PR #58828:
URL: https://github.com/apache/doris/pull/58828#discussion_r2601792293
##########
fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/PrivTable.java:
##########
@@ -74,25 +74,22 @@ public PrivEntry addEntry(PrivEntry entry, boolean
errOnExist, boolean errOnNonE
}
}
- PrivEntry existingEntry = getExistingEntry(newEntry);
- if (existingEntry == null) {
+ int idx = Collections.binarySearch(entries, newEntry);
+ if (idx < 0) {
if (errOnNonExist) {
throw new DdlException("entry does not exist");
}
- entries.add(newEntry);
- Collections.sort(entries);
- LOG.info("add priv entry: {}", newEntry);
+ int insertPos = -idx - 1;
+ entries.add(insertPos, newEntry);
return newEntry;
- } else {
- if (errOnExist) {
- throw new DdlException("entry already exist");
- } else {
- mergePriv(existingEntry, newEntry);
- if (LOG.isDebugEnabled()) {
- LOG.debug("merge priv entry: {}", existingEntry);
- }
- }
}
+
+ PrivEntry existingEntry = entries.get(idx);
+ if (errOnExist) {
Review Comment:
move the check up the line 87
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]