Matter: Update profile parsing from ipairs to pairs#2807
Matter: Update profile parsing from ipairs to pairs#2807hcarter-775 wants to merge 1 commit intomainfrom
Conversation
|
Invitation URL: |
Test Results 72 files 487 suites 0s ⏱️ Results for commit f9fec6e. ♻️ This comment has been updated with latest results. |
|
matter-lock_coverage.xml
matter-sensor_coverage.xml
matter-switch_coverage.xml
Minimum allowed coverage is Generated by 🐒 cobertura-action against f9fec6e |
| local prev_cap_ids = {} | ||
| for _, capability in ipairs(prev_component.capabilities or {}) do | ||
| for _, capability in pairs(prev_component.capabilities or {}) do | ||
| prev_cap_ids[capability.id] = true |
There was a problem hiding this comment.
nit: Since component.capabilities are already keyed by capability ID, I don't think we need to build up the new table but I don't think we need to change it if it has already been tested as is
There was a problem hiding this comment.
yeah, I think I did this to try and be clever. The idea was that I loop through this once and make the table, so now when I loop through the other list I just check in O(1) if the key exists, therefore making this a O(n) + O(n) operation rather than O(n^2).
Of course, we're talking a speed up on max 10 values so this is likely slowing things down or doing nothing at all.
00b2346 to
f9fec6e
Compare
Description of Change
Upon investigation, the structure of the
profiletable object being parsed is slightly different than what is expected here. Specifically, thecapabilitiestable has explicit string keys rather than the ordered integer keys that were initially expected. Therefore, the size check for thecapabilitiestable will always returns 0, and the loop needs to usepairsinstead ofipairs.To note, the integration test framework handles these profiles as a ordered-numerical table (which the original implementation had assumed to be correct).
Summary of Completed Tests
Tested on-device.