Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ Programming ➜ General ➜ Self-managed hashed strings

Self-managed hashed strings

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3  4 

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #45 on Sun 05 Mar 2006 02:08 AM (UTC)

Amended on Sun 05 Mar 2006 02:09 AM (UTC) by David Haley

Message
Yes, it's a shared-string manager. It makes sure that you only have one instance of every string in memory. And it's completely automatic -- no need to worry about STRALLOC and STRFREE vs. DISPOSE, str_dup, etc.

It's not quite a complete substitute for std::string -- it has a few common methods that I've needed but hardly all. That being said, you can call shared_str.str() to get a const std::string& for whatever you'd need to do.

The documentation, while not stellar, isn't too bad -- hopefully it should help explain what's going on and how to use it.

I'm almost done with a near-complete switchover in my code base from old to new string management. I'll have some memory statistics shortly. I'm not expecting much of a memory gain, but you never know. And I have no way of easily measuring CPU use, so I won't bother with that.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #46 on Sun 05 Mar 2006 03:14 AM (UTC)
Message
Quote:
Has anybody tried integrating this into a MUD yet?


I do plan to use it in my base. It is just hard to find time to play with it much while school is winding down to spring break.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #47 on Wed 15 Mar 2006 03:53 AM (UTC)
Message
Your library is now fully integrated with my mud. :)

~Nick Cash
http://www.nick-cash.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #48 on Wed 15 Mar 2006 05:11 AM (UTC)
Message
Great! Did you have any problems? How is it going for you?

I finished mine as well. It was a horribly tedious process removing the STRALLOCs etc. but I feel much safer now that the majority of them are gone. (I did keep a few just because I was tired of changing everything.) I think it's using about another megabyte of memory, but I'm not entirely sure and it's hard to take exact measurements. I imagine this is due to the overhead of the hash table, but it's a little more than I expected. I'll have to check out the implementation of the buckets and see if I can't come up with something more efficient. (My first implementation was just something "quick and dirty" to make sure that it worked.)

Most important to me would be feedback on the interface of the shared string. Do you find yourself wanting more methods to the underlying string? (e.g. substr, etc.) I found that generally it worked out quite well for me, once I added the +, += and < operators. (I needed < to store the shared_strs in a map.)

Also, is the documentation good? Any places where it wasn't clear, and/or could be better?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #49 on Wed 15 Mar 2006 07:00 AM (UTC)
Message
My base is built from Scratch and doesnt really employ the library to its full extent too well, though that will soon change. Thus, I don't really have any problems just yet. I'll be sure to report back once the base perks up and objects/mobs start making more of an appearance.

Installation was nice and easy, especially since you provided an example program. The only problem I had was due to my own stupidity (I had forgotten I had an older version of the include files laying around...).

For the things I was doing, though rather brief, the + and += methods, along with str() and c_str(), handled everything I needed. A few more methods that the std::string class employs might be useful (substr, etc.) as well, though I doubt it would really be needed.

The documentation was very helpful. I wasn't quite sure what I could and could not do, and it until I read the documentation. It, along with the example program, made it very clear.

Overall it seemed very clear, and everything worked very easily. Definitely one of the best libraries I've delt with in recent times.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #50 on Wed 15 Mar 2006 12:26 PM (UTC)
Message
I'm still planning to make use of this code, I just haven't had the time to do anything with it yet. It looks like it should do exactly what I want though.

I can forsee that adding substr, find, and replace methods would be a huge help if that's at all possible. I have several spots in the code where that would be useful since I'm already using std::string for those now.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #51 on Mon 20 Mar 2006 04:15 AM (UTC)
Message
Version 0.9.f is released. It includes implementation of the < operator, in addition to some more documentation.

I removed the distinction between str and str_const, in favor of only using the constant version. There isn't really any reason to have a method that returns a copy; if you need a copy you can grab the reference and copy that.

On the web page I note some future plans:
http://david.the-haleys.org/index.php?page=shared-str

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


125,713 views.

This is page 4, subject is 4 pages long:  [Previous page]  1  2  3  4 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.