Re: Large binary data manipulation
From: Khamis (khamis_at_wellcode.com)
Date: 08/26/04
- Next message: Khamis Abuelkomboz: "Re: brainstorm on moving treectrl to the core (was Re: treectrl !)"
- Previous message: USCode: "Re: Large binary data manipulation"
- In reply to: Wellcode: "Re: Large binary data manipulation"
- Next in thread: Khamis Abuelkomboz: "Re: Large binary data manipulation"
- Reply: Khamis Abuelkomboz: "Re: Large binary data manipulation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Next message: Khamis Abuelkomboz: "Re: brainstorm on moving treectrl to the core (was Re: treectrl !)"
- Previous message: USCode: "Re: Large binary data manipulation"
- In reply to: Wellcode: "Re: Large binary data manipulation"
- Next in thread: Khamis Abuelkomboz: "Re: Large binary data manipulation"
- Reply: Khamis Abuelkomboz: "Re: Large binary data manipulation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|