Posted to tcl by patthoyts at Tue Jun 10 22:45:10 GMT 2008view raw

  1. % proc t1 {} {variable data; binary encode hex $data}
  2. % proc t2 {} {variable data; binary encode hex -state data ""}
  3. % set data [binary format @102400] ; string length [t1]
  4. 204800
  5. % set data [binary format @102400] ; string length [t2]
  6. 204800
  7. % set data [binary format @102400] ; time {t1} 10
  8. 1755.9 microseconds per iteration
  9. % set data [binary format @102400] ; time {t2} 10
  10. 218.6 microseconds per iteration
  11.  
  12. The C function accesses these Tcl_Obj's using:
  13. data = input = Tcl_GetByteArrayFromObj(objv[objc-1], &count);
  14. if (stateObj) {
  15. data = state = Tcl_GetByteArrayFromObj(stateObj, &state_count);
  16. count += state_count;
  17. }
  18. and then I move the 'data' pointer along the state data first then the input data. So the C code is identical for each calling method.