FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#2
|
||||
|
||||
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 |
|
|
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 |
|