Fixes regarding to comments in ag/2839267

1. use struct {} to instantiate privacy fields for efficiency reason
2. use vector<uint8_t>* instead of vector<uint8_t>& to indicate the
caller knows the value gets changed.
3. binary search privay policy for sections

Bug: 65595927
Test: unit test covers
Change-Id: Ic58c2f607465d1a7f10352b9a38c3d8b1a5cf352
diff --git a/cmds/incidentd/src/Section.cpp b/cmds/incidentd/src/Section.cpp
index 6f052de..166fef0 100644
--- a/cmds/incidentd/src/Section.cpp
+++ b/cmds/incidentd/src/Section.cpp
@@ -97,13 +97,19 @@
 static const Privacy*
 get_privacy_of_section(int id)
 {
-    if (id < 0) return NULL;
-    int i=0;
-    while (PRIVACY_POLICY_LIST[i] != NULL) {
-        const Privacy* p = PRIVACY_POLICY_LIST[i];
-        if (p->field_id == (uint32_t)id) return p;
-        if (p->field_id > (uint32_t)id) return NULL;
-        i++;
+    int l = 0;
+    int r = PRIVACY_POLICY_COUNT - 1;
+    while (l <= r) {
+        int mid = (l + r) >> 1;
+        const Privacy* p = PRIVACY_POLICY_LIST[mid];
+
+        if (p->field_id < (uint32_t)id) {
+            l = mid + 1;
+        } else if (p->field_id > (uint32_t)id) {
+            r = mid - 1;
+        } else {
+            return p;
+        }
     }
     return NULL;
 }