473,796 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

fastest way to load NON-readonly files.

i have searched around for an answer to this question,
but haven't found a satisfactory answer.

i understand things like mmap(2) can be used to quickly load
a file - but it seems to be a function for "read-only" situtations.
it doesn't appear to be useful in situations where editing must be
done on the loaded file.

the next fastest method (based on my searches) seemed to be
a fread(3)/read(2) loop. however, malloc(3)'s seems to slow
this down to an incredible extent.

--

the best way i could think to load a file for editing was
to load a file into a pointer to line pointers (each line
malloc'd for). however, on files with 10's and 100's of
thousands of lines, this process takes FOREVER. i am
reading line 150,000 half an hour later on a 500MHz
FBSD machine. there's actually 3 malloc() calls per line.
1 to increase the allocation to a pointer to line lengths,
1 to increase the allocation to pointers to lines,
and 1 to allocate space for the actual line.

i know there's a better way - but what is it?
my 'joe editor' can load a 20MB file in 1-2 seconds.
i can't figure out how to do it in under an hour! heh.
(unfortunately, "joe" code is undreadable!).

thank you.
Nov 13 '05 #1
0 1509

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
32660
by: Rune Strand | last post by:
Hi, If I have a lot of integers and want do something with each digit as integer, what is the fastest way to get there? Eg. Make 12345 into an iterable object, like or "12345" (Btw: What is the English term for this process; itemize? tokenize? digitize? sequence?) Some examples:
4
3562
by: laurenq uantrell | last post by:
I am trying to determine which of three stored procedure designs are fastest in the Query Analyzer: One query is a straight SELECT query with all desired rows and a dozen (tblName.RowName = @param or @param = Null) filters in the WHERE statement. One query populates a #Temp table with the UniqueIDs from the results of the SELECT query in the above example, then joins that #Temp table to get the desired rows.
11
2118
by: Ignacio X. Domínguez | last post by:
Hi. I'm developing a desktop application that needs to store some data in a local file. Let's say for example that I want to have an address book with names and phone numbers in a file. I would like to be able to retrieve the name by searching for a given phone number the fastest I can. I have considered the posibility of using XmlTextReader with something like: <list> <item number="1234567"> <name>John Doe</name>
5
2843
by: Gaurav - http://www.gauravcreations.com | last post by:
what is the fastest method to sort and load 1 lakh + strings in a list box from a text file. each string is in a new line -- Gaurav Creations
3
3520
by: Sehboo | last post by:
I have to call a stored procedure which returns about 1000 rows with about 5 fields (most of them are int). What is the fastest way to load this data? if I just do DataTable.Load, then is it fast? or should I do something else? Thanks
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10228
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10173
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.