Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Remove QR detection LRU cache

Amrithesh Kakkoth Entee483ac6303b1
diff --git a/mobile/apps/photos/lib/ui/viewer/file/qr_code_detection_helper.dart b/mobile/apps/photos/lib/ui/viewer/file/qr_code_detection_helper.dart
index 1a95ab1d01..58df510f4a 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/qr_code_detection_helper.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/qr_code_detection_helper.dart
@@ -1,5 +1,4 @@
import "dart:async";
-import "dart:collection";
import "dart:io";
import "package:ente_qr/ente_qr.dart";
@@ -11,18 +10,12 @@ import "package:photos/utils/file_util.dart";
class QrCodeDetectionHelper {
static const _debounceDuration = Duration(milliseconds: 500);
- static const _maxCacheSize = 20;
-
final Logger _logger = Logger("QrCodeDetectionHelper");
final EnteQr _enteQr = EnteQr();
final ValueNotifier<List<QrDetection>> qrDetectionsNotifier =
ValueNotifier<List<QrDetection>>(const []);
- /// LRU cache keyed by file tag (unique identifier).
- final LinkedHashMap<String, List<QrDetection>> _cache =
- LinkedHashMap<String, List<QrDetection>>();
-
int _requestId = 0;
bool _disposed = false;
Timer? _debounceTimer;
@@ -38,14 +31,6 @@ class QrCodeDetectionHelper {
return;
}
- // Return cached result immediately if available
- final cached = _cache[file.tag];
- if (cached != null) {
- _logger.info("QR cache hit: found=${cached.length}");
- qrDetectionsNotifier.value = cached;
- return;
- }
-
qrDetectionsNotifier.value = const [];
_debounceTimer = Timer(_debounceDuration, () {
@@ -87,9 +72,6 @@ class QrCodeDetectionHelper {
"found=${detections.length}",
);
- // Cache the result
- _cacheResult(file.tag, detections);
-
if (_disposed || requestId != _requestId) return;
qrDetectionsNotifier.value = detections;
@@ -100,16 +82,6 @@ class QrCodeDetectionHelper {
}
}
- void _cacheResult(String fileId, List<QrDetection> detections) {
- // Move to end (most recently used)
- _cache.remove(fileId);
- _cache[fileId] = detections;
- // Evict oldest entry if over limit
- if (_cache.length > _maxCacheSize) {
- _cache.remove(_cache.keys.first);
- }
- }
-
bool _isFileEligible(EnteFile file) {
return file.fileType == FileType.image ||
file.fileType == FileType.livePhoto;
@@ -118,7 +90,6 @@ class QrCodeDetectionHelper {
void dispose() {
_disposed = true;
_debounceTimer?.cancel();
- _cache.clear();
qrDetectionsNotifier.dispose();
}
}