[ Home | CW Bug Reports | Mail ]

UAEDesc::AddPtr()高速化
Subject: SUG -- performance of UAEDesc::AddPtr()
 
---------------------------------------------------------------------------
METROWERKS PRODUCT AND USAGE SECTION
 
Product name :            [ CodeWarrior Professional ]
Product version :         [ Pro 4 ]
Component name :          [ PowerPlant ]
Generating:               [ Mac OS 68K / Mac OS PowerPC ]
Purpose:                  [ application ]
 
---------------------------------------------------------------------------
SUGGESTION
 
UAEDesc::AddPtr() is one of the AEOM processing bottle-neck routines.
LModelObject::PutInToken() etc are using this method often. So, you
should write the fastest code as possible.
Here is my code.
 
void
UAEDesc::AddPtr(
    AEDesc          *ioDesc,        //  io descriptor or descriptor list
    long            inIndex,        //  new/replace sub descriptor position
                                    //      (0 for append/don't care)
    DescType        inDescType,     //  new/replace sub descripter type
    const void      *inDataPtr,     //  pointer to date for new sub descriptor
    Size            inDataSize)     //  size of data in inDataPtr
{
OSErr   err = noErr;
    
    if (ioDesc->descriptorType == typeNull) {
        err = ::AECreateDesc(inDescType,inDataPtr,inDataSize,ioDesc);
        ThrowIfError_(err);
        return;
    }
                                    // Must end up being some sort of list
                                    //   make descriptor a list
    if (ioDesc->descriptorType != typeAEList) {
        AEDesc  tempList;
        err = ::AECoerceDesc(ioDesc,typeAEList,&tempList);
        ThrowIfError_(err);
        ::AEDisposeDesc(ioDesc);
        *ioDesc = tempList;
    }   
                                    // Add data to the list
    err = ::AEPutPtr(ioDesc,inIndex,inDescType,inDataPtr,inDataSize);
    ThrowIfError_(err);
}


この Pageは MacOS X + Radio UserLand で作っています。