|
Rockbox mail archiveSubject: Re: some propositionsRe: some propositions
From: Paul Suade <paul.suade_at_laposte.net>
Date: Sat, 22 Jun 2002 11:18:50 +0200 > Hi,all > > I'd like to propose to update the following structure to store the directory entries : > > in file: apps\tree.c > > struct entry { > bool file; /* true if file, false if dir */ > char name[TREE_MAX_FILENAMELEN]; > }; One possibility : struct entry { int type; /* bit 31 = 0 if file, bit 0..30 = type */ char name[TREE_MAX_FILENAMELEN]; }; To test if a file, just the following conditional (e->type >= 0) which gives a good code (just one opcode !). Or another one : struct entry { struct vmt_entry *vmt; char name[TREE_MAX_FILENAMELEN]; }; struct vmt_entry { bool (*is_file) (); int (*type) (); ... (*tree_enter) (...); ... }; This one would need more drastic changes in source, but it calls the right functions without wasting time in switch statement. For each new file type just intance a new vmt with the right functions pointers to handle this kind of file. You still need a type factory function with a switch statement to set the right vmt on an entry. Received on 2002-06-22 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |