Re: Large binary data manipulation

From: Khamis (khamis_at_wellcode.com)
Date: 08/26/04


Date: Thu, 26 Aug 2004 00:31:24 +0200

Wellcode wrote:

> Hi Derek
>
> you have two problems in your example:
>
> your first problem is the reading 2 bytes every step. this causes alot
> of io operations. The second problem, that you don't use the append
> command, your method reallocates the buffer every time you set a new
> variable value.
> Just read larger buffers and the routines get alot faster.
>
> set data [read $file_handle 10240]
> set len [string length $data]
> set left_data ""
> set right_data ""
> for {set i 0} {$i < $len} {incr i 4} {
> append left_data [string range $data $i [expr $i+1]]
> append right_data [string range $data [expr $i+2] [expr $i+3]]
> }
>
> regards

This sounds for me a good solution, but if I think on my programs in c
source code, I would never use i++ if the variable is not set.
So "set i 0" must be placed somewhere in your source code before calling
"incr i" and you don't need to validate it's exist.

It sounds like tcl is more saver than bad c source code :-)

regards

-- 
Try Code-Navigator on http://www.codenav.com
a source code navigating, analysis and developing tool. It supports 
almost all languages on the scope.


Relevant Pages

  • Re: How to Parse NDIS_WLAN_BSSID_EX???
    ... If you are ready to look my source code. ... With regards ... // Possibly Examine Extended BSSID Fields ... The code fragments provided are from a ...
    (microsoft.public.development.device.drivers)
  • Re: [PATCH, RFC 0/3] Improvements to the tracing documentation
    ... I haven't played with them yet, but I was looking over the source code ... time we print a line in the tracing buffer! ... MAJOR/MINOR encoding. ... input to the filter predicate would probably be a really good thing to ...
    (Linux-Kernel)
  • Re: Embedding perl in Java
    ... Regards ... It didnt work on windows though(like it ... Whether people have the source code or not doesn't stop ... I'm not too fond about these license things. ...
    (comp.lang.perl.misc)
  • RE: Unable to boot Windows CE through HD
    ... Have a look at the source code of the biosloader ... In debug.h you can see that the error codes you get mean: ... Read buffer should be at least a cluster size ... not to overwrite BIOS Parameter Block and rebuild the biosloader. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: How to check whether executing in atomic context?
    ... On Thu, Oct 15, 2009 at 12:45 AM, Stefan Richter ... functionality via instrumenting his source code, ... I preallocate a buffer at module init time. ...
    (Linux-Kernel)