Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 12-04-2006
Avatar de halcon_rojo
halcon_rojo halcon_rojo is offline
Miembro
 
Registrado: abr 2006
Posts: 14
Poder: 0
halcon_rojo Va por buen camino
Cool para quien le entienda

>Hello,
>>Someone knows the exact limits of TStringList.LoadFromFile ?
>>- file size ?
>- max lines ?
>- ctrl_Z in file ?
>>(I know it stops on nulls).

I don't think there should be specific filesize or maxline limits other
than those that are imposed by the
process. LoadFromFile calls LoadFromStream which calls Read which calls
HandleStream.Read which
calls FileRead which returns a pointer to a buffer and a count of the bytes
read ( a DWORD so there is a 2gb or is it 4gb limit there).

the Tstrings.LoadFromStream
looks like
Size := Stream.Size - Stream.Position;
SetString(S, nil, Size);
Stream.Read(Pointer(S)^, Size);
SetTextStr(S);
so it is clear that there is a 1 hit read of all the data on that file
until the end of file (which might not be what
you want if you have other stuff on the file). Anyway, all the data goes
into an ansistring S (which is local and will be deallocated on exit) but
afaik the memory for the underlying buffer is never freed until the
handle is finally freed .. this seems wasteful (as in, as soon as we have
finished the load we could release
the file buffer .. but I may have misread the code).

Next we have SetTextStr which is a loop that looks like so

P := Pointer(Value);
if P <> nil then
while P^ <> #0 do
begin
Start := P;
while not (P^ in [#0, #10, #13]) do Inc(P);
SetString(S, Start, P - Start);
Add(S);
if P^ = #13 then Inc(P);
if P^ = #10 then Inc(P);
end;

(I am sure Borland will forgive me for publishing this code snippet, in the
interests of science).

So, there are some possibilities of some oddities here particularly wrt
#0,#10,#13.
The #10 and #13 were put there by GetTextStr .. but you might have had
them embedded in
your original source strings. The #0 .. again, you may have had a reason
for having one or more
consecutive empty strings in your original list.

Note also the call to Add .. depending upon your settings of Sorted and, if
sorted, Duplicates this can end up
with another call to the bsearch find and Insert (even if you KNOW you are
restoring a sorted list), and some locale dependencies.


My point is that TstringList.SaveToFile and LoadFromFile are not the simple
mirror image dump and
restore of blocks of characters that one might expect. There is quite a
lot of looping and comparison and memory management going on under the
hood, so if your strings have unusual content or you need to do a lot of
this ,you might be better off considering alternative structures.

fwiw
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Capacidad de Paradox irvingcm Tablas planas 3 13-04-2005 00:41:59
Cual es el limite de capacidad de Paradox? URBANO Tablas planas 1 15-03-2005 09:54:12
Saber exactamente cual es cual en un DBLookUpComboBox bustio OOP 3 03-02-2005 23:16:58
Capacidad del QReport marila Impresión 2 22-04-2004 16:02:47
Capacidad No soportada con BDE GIVO Conexión con bases de datos 3 27-08-2003 03:10:09


La franja horaria es GMT +2. Ahora son las 15:45:11.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi