Re: structure _Atom and _AtomList usage

Juliusz Chroboczek <[email protected]>
Newsgroups gmane.comp.web.polipo.user
Message-ID <[email protected]>
> Can someone please help me to understand what is the use of _Atom and
> _AtomList structures. Its not very clear to me, can't I use a
> character buffer instead. A detailed explanation will be really
> helpful.

Sure.

An atom is an interned, read-only, reference-counted string.

In other words, it's just like a string, but you cannot modify an
atom, you need to create a new one.  Additionally, pointer equality is
equivalent to structural equality on atoms -- you don't need to strcmp
atoms, you just check that the AtomPtrs are equal.

Atoms are used extensively in Polipo to represent HTTP headers.  First,
because they can be compared in constant time, ; before I modified it to
use atoms, Polipo was spending 60% CPU in the HTTP parser.  Second, they
save memory, since the same strings usually appear in many different
HTTP headers -- a typical Polipo instance stores just a few hundred
atoms that are used to encode many thousands of HTTP headers.

-- Juliusz

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.