Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: Append menu is slow. Keywords: AppendMenu menu slow efficiency Message-ID: <29122@ucbvax.BERKELEY.EDU> Date: 10 May 89 01:20:00 GMT References: <89May9.171757edt.11077@ephemeral.ai.toronto.edu> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Organization: School of Education, UC-Berkeley Lines: 19 In article <89May9.171757edt.11077@ephemeral.ai.toronto.edu> dudek@ai.toronto.edu (Gregory Dudek) writes: > I am using AppendMenu to make some big menus and it is slowwwwww (i.e. on >the order of 5 seconds on a Mac Plus). AppendMenu doesn't know that you are going to be calling it again immediately, so it calls CalcMenuSize(), which does a linear scan over the menu to see how wide the menu should be by doing a StringWidth() on each item. The structure of menus is documented in Inside Mac. Menu items are basically pascal strings followed by four bytes of extra information. At the end of the muenu is a null byte. You can use Munger to insert items into a menu, then call CalcMenuSize() yourself after you are all done. If you are really paranoid, you can copy and renumber the current menu definition procedure and set up your menu to use it. That will guarantee that if Apple ever changes the format of standard menus, and the MDEF to run them, that your menus will still work. I think this is over-paranoia myself.