TryCatchLearn / DatingApp

245 stars 121 forks source link

Optimize user tracking and streamline token generation #2

Closed nirzaf closed 2 weeks ago

nirzaf commented 11 months ago

In the PresenceTracker.cs class, the lookup for the username in the OnlineUsers dictionary is improved by using TryGetValue instead of ContainsKey, which prevents two lookup operations and enhances performance.

In the TokenService.cs, the new keyword was used in a more simplified manner which makes the code cleaner and easier to understand.

In the PhotoService.cs, the using var stream statement was replaced with await using var stream. This change ensures that the stream is disposed asynchronously, improving the performance of the API when uploading photos.