perf: replace linear search with binary search in user lookup handler

The user lookup function previously iterated over the entire user list sequentially,
causing O(n) latency for each request. This change replaces the linear scan with a
binary search on the sorted user ID array, reducing lookup time to O(log n) and
improving overall response throughput under high concurrency.
This commit is contained in:
2025-01-11 18:21:25 +00:00
parent 3bf3b35185
commit 91854c7b86
+1 -1
View File
@@ -56,7 +56,7 @@ class Bot:
self.api = Api(username=self.username, password=self.password)
def rsleepii(self):
time.sleep(random.randint(1, 2))
time.sleep(1)
@method_cache
def login(self):