[AI Task] Pre-size MediaVision result lists with known native count - #7786
Open
JoonghyunCho wants to merge 1 commit into
Open
[AI Task] Pre-size MediaVision result lists with known native count#7786JoonghyunCho wants to merge 1 commit into
JoonghyunCho wants to merge 1 commit into
Conversation
…ixes #7700) The five Inference*Result constructors and four legacy GetResults helpers read the exact element count from native code but built their List<T> with default capacity, causing repeated backing-array reallocations on the per-frame hot path. Pass the known count/number as the initial capacity so a single right-sized array is allocated. List contents and order are unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Member
Author
|
|
Member
Author
|
🤖 [AI Review] Reviewed — no findings. Scope checked:
No 🔴 critical issues, no 🟡 suggestions to flag. Automated review — final merge decision rests with human reviewers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The five
Inference*Resultconstructors read the exact elementcountfrom native code, then built theirList<T>with the default (zero) capacity andAdd()-ed in acount-bounded loop. Since each result is constructed once per inferred frame (17+ points for pose landmarks, 68+ for facial landmarks), the ignored count caused ~3–5 avoidable backing-array reallocations plus element copies per frame. All five constructors — and the four legacyGetResultshelpers with the same shape — now pass the already-known count as the initialList<T>capacity, so one right-sized array is allocated instead of a geometric growth chain. List contents and order are unchanged.Changes
src/Tizen.Multimedia.Vision/MediaVision/InferencePoseLandmarkDetectorResult.cs:new List<Point>()→new List<Point>((int)count)src/Tizen.Multimedia.Vision/MediaVision/InferenceFacialLandmarkDetectorResult.cs:new List<Point>()→new List<Point>((int)count)src/Tizen.Multimedia.Vision/MediaVision/InferenceFaceDetectorResult.cs:new List<Rectangle>()→new List<Rectangle>((int)count)src/Tizen.Multimedia.Vision/MediaVision/InferenceObjectDetectorResult.cs:new List<Rectangle>()→new List<Rectangle>((int)count)src/Tizen.Multimedia.Vision/MediaVision/InferenceImageClassifierResult.cs:new List<string>()→new List<string>((int)count)src/Tizen.Multimedia.Vision/MediaVision/FaceDetector.cs: legacyGetResultslist pre-sized withnumbersrc/Tizen.Multimedia.Vision/MediaVision/ObjectDetector.cs: legacyGetResultslist pre-sized withnumbersrc/Tizen.Multimedia.Vision/MediaVision/ImageClassifier.cs: legacyGetResultslist pre-sized withnumbersrc/Tizen.Multimedia.Vision/MediaVision/FacialLandmarkDetector.cs: legacyGetResultslist pre-sized withnumberMode
Refactoring
Verification
Fixes #7700