| 290 | } |
| 291 | |
| 292 | AbstractClassRep *AbstractClassRep::getCommonParent( const AbstractClassRep *otherClass ) const |
| 293 | { |
| 294 | // CodeReview: This may be a noob way of doing it. There may be some kind of |
| 295 | // super-spiffy algorithm to do what the code below does, but this appeared |
| 296 | // to make sense to me, and it is pretty easy to see what it is doing [6/23/2007 Pat] |
| 297 | |
| 298 | static VectorPtr<AbstractClassRep *> thisClassHeirarchy; |
| 299 | thisClassHeirarchy.clear(); |
| 300 | |
| 301 | AbstractClassRep *walk = const_cast<AbstractClassRep *>( this ); |
| 302 | |
| 303 | while( walk != NULL ) |
| 304 | { |
| 305 | thisClassHeirarchy.push_front( walk ); |
| 306 | walk = walk->getParentClass(); |
| 307 | } |
| 308 | |
| 309 | static VectorPtr<AbstractClassRep *> compClassHeirarchy; |
| 310 | compClassHeirarchy.clear(); |
| 311 | walk = const_cast<AbstractClassRep *>( otherClass ); |
| 312 | while( walk != NULL ) |
| 313 | { |
| 314 | compClassHeirarchy.push_front( walk ); |
| 315 | walk = walk->getParentClass(); |
| 316 | } |
| 317 | |
| 318 | // Make sure we only iterate over the list the number of times we can |
| 319 | S32 maxIterations = getMin( compClassHeirarchy.size(), thisClassHeirarchy.size() ); |
| 320 | |
| 321 | U32 i = 0; |
| 322 | for( ; i < maxIterations; i++ ) |
| 323 | { |
| 324 | if( compClassHeirarchy[i] != thisClassHeirarchy[i] ) |
| 325 | break; |
| 326 | } |
| 327 | |
| 328 | return compClassHeirarchy[i]; |
| 329 | } |
| 330 | |
| 331 | //------------------------------------------------------------------------------ |
| 332 | //-------------------------------------- ConsoleObject |
no test coverage detected