You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/12/02 20:27:03 UTC

[GitHub] [mynewt-core] nkaje commented on a change in pull request #2425: log_fcb: optimize finding records towards the end of circular buffer

nkaje commented on a change in pull request #2425:
URL: https://github.com/apache/mynewt-core/pull/2425#discussion_r534459492



##########
File path: sys/log/full/src/log_fcb.c
##########
@@ -102,17 +132,24 @@ log_fcb_find_gte(struct log *log, struct log_offset *log_offset,
     }
 #endif
 
-    /* Keep advancing until we find an entry with a great enough index. */
-    do {
-        rc = log_read_hdr(log, out_entry, &hdr);
-        if (rc != 0) {
-            return rc;
-        }
+    if (fcb->f_oldest == fcb->f_active.fe_area) {
+        fap = fcb->f_oldest;
+    } else {
+        /* start from one before */
+        fap = (fcb->f_active.fe_area - sizeof(struct flash_area));
+    }
 
-        if (hdr.ue_index >= log_offset->lo_index) {
-            return 0;
-        }
-    } while (fcb_getnext(fcb, out_entry) == 0);
+    lwga.log            = log;
+    lwga.log_offset     = log_offset;
+    lwga.fcb_entry      = out_entry;
+    rc = fcb_walk(fcb, fap, fcb_walk_gte, (void *)&lwga);
+    /* Not found, try the active area */
+    if (rc == 0) {
+        fap = fcb->f_active.fe_area;
+        rc  = fcb_walk(fcb, fap, fcb_walk_gte, (void *)&lwga);
+    }
+
+    assert(rc == FCB_FOUND);

Review comment:
       expect to find every time, not sure assert is the right thing to do here though.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org