Changeset 454 for branches/thune/thread_safe/context.c
- Timestamp:
- 08/27/07 21:01:11 (15 months ago)
- Files:
-
- 1 modified
-
branches/thune/thread_safe/context.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/thune/thread_safe/context.c
r431 r454 303 303 304 304 /** 305 Add word to context if it does not already exist. 306 If added, the word is initialied as unset. 307 308 \return Index of word in context. 309 */ 310 int ur_internWordT( UThread* ut, const UContext* ctx, UAtom atom ) 311 { 312 int wrdN; 313 UBlock* vblk; 305 Find word in context by atom. 306 \return Word index or -1 if not found. 307 */ 308 static int _lookupNoSort( UThread* ut, const UContext* ctx, UAtom atom ) 309 { 314 310 UBlock* wblk; 315 311 UCell* it; 316 312 UCell* end; 317 318 319 // Lookup word.320 313 321 314 wblk = ur_blockPtr( ctx->ctx.wordBlk ); … … 331 324 ++it; 332 325 } 326 return -1; 333 327 } 334 328 else 335 329 { 336 wrdN = _binarySearch( it, wblk->used, atom ); 337 if( wrdN > -1 ) 338 return wrdN; 339 } 340 341 342 // Not found - add new word. 343 330 return _binarySearch( it, wblk->used, atom ); 331 } 332 } 333 334 335 static int _internWord( UThread* ut, const UContext* ctx, UAtom atom ) 336 { 337 int wrdN; 338 UBlock* vblk; 339 UBlock* wblk; 340 UCell* it; 341 342 wblk = ur_blockPtr( ctx->ctx.wordBlk ); 344 343 wrdN = wblk->used; 345 344 UR_EXPAND_1( UCell, wblk, it ); … … 365 364 366 365 return wrdN; 366 } 367 368 369 /** 370 Add word to context if it does not already exist. 371 If added, the word is initialied as unset. 372 373 \return Index of word in context. 374 */ 375 int ur_internWordT( UThread* ut, const UContext* ctx, UAtom atom ) 376 { 377 int wrdN; 378 379 wrdN = _lookupNoSort( ut, ctx, atom ); 380 if( wrdN > -1 ) 381 return wrdN; 382 383 // Not found - add new word. 384 return _internWord( ut, ctx, atom ); 367 385 } 368 386 … … 571 589 { 572 590 --cit; 573 wrdN = ur_lookup(cit, atom );591 wrdN = _lookupNoSort( ut, cit, atom ); 574 592 if( wrdN > -1 ) 575 593 goto assign; … … 594 612 // Word not found, so intern into current module (top of context stack). 595 613 cit = ctop - 1; 596 wrdN = ur_internWord(cit, atom );614 wrdN = _internWord( ut, cit, atom ); 597 615 598 616 assign:
