On Wed, May 9, 2012 at 10:25 AM, Nguyen Thai Ngoc Duy <pclouds@xxxxxxxxx> wrote: > On Tue, May 8, 2012 at 11:11 PM, Jeff King <peff@xxxxxxxx> wrote: >> On Tue, May 08, 2012 at 08:14:30PM +0700, Nguyen Thai Ngoc Duy wrote: >>> @@ -473,7 +474,19 @@ static int peel_onion(const char *name, int len, unsigned char *sha1) >>> expected_type = OBJ_NONE; >>> else if (sp[0] == '/') >>> expected_type = OBJ_COMMIT; >>> - else >>> + else if (!strncmp("note}", sp, 5)) { >>> + const unsigned char *note; >>> + struct notes_tree t; >>> + if (get_sha1_1(name, sp - name - 2, outer)) >>> + return -1; >>> + memset(&t, 0, sizeof(t)); >>> + init_notes(&t, NULL, NULL, 0); >>> + note = get_note(&t, outer); >>> + if (note) >>> + hashcpy(sha1, note); >>> + free_notes(&t); >>> + return note ? 0 : -1; >>> + } else >> >> The notes code is relatively expensive to initialize, with the >> assumption that the effort will be amortized across multiple lookups >> (which are made faster). Is it possible to cache this initialized notes >> structure in case many lookups are done? > > No idea. I have never worked/used notes until yesterday (and these > patches were the result). I will look into it. IIRC, the initialization loads the top-level notes tree object into memory. Subtrees (if any) are loaded on demand. FTR, if you have less then ~256 notes in the notes tree, there will be no subtrees. As the number of notes grows, the number of subtree levels grow roughly logarithmically with the total number of notes (see determine_fanout() for more details). ...Johan -- Johan Herland, <johan@xxxxxxxxxxx> www.herland.net -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html