Hongten opened a new issue, #18586:
URL: https://github.com/apache/pulsar/issues/18586

   ### Search before asking
   
   - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) 
and found nothing similar.
   
   
   ### Motivation
   
   To optimize the method computeLocalQuota() in ResourceQuotaCalculatorImpl 
class. We can move `confUsage` before the `totalUsage`. 
   Please refer to [if (confUsage < 0) 
{](https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceQuotaCalculatorImpl.java#L40)
   
   ### Solution
   
   We can move `confUsage` before the `totalUsage`. 
   
   e.g.
   ```
   if (confUsage < 0) {
       // This can happen if the RG is not configured with this particular 
limit (message or byte count) yet.
       val retVal = -1;
       if (log.isDebugEnabled()) {
           log.debug("Configured usage ({}) is not set; returning a special 
value ({}) for calculated quota",
                   confUsage, retVal);
       }
       return retVal;
   }
   
   long totalUsage = 0;
   
   for (long usage : allUsages) {
       totalUsage += usage;
   }
   ```
   
   ### Alternatives
   
   N/A
   
   ### Anything else?
   
   N/A
   
   ### Are you willing to submit a PR?
   
   - [X] I'm willing to submit a PR!


-- 
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]

Reply via email to