edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Adam Thompson <arthompson1990@gmail.com>
To: Karl Dahlke <eklhad@comcast.net>
Cc: Edbrowse-dev@lists.the-brannons.com
Subject: Re: [Edbrowse-dev] tag list
Date: Sat, 1 Mar 2014 19:01:14 +0000	[thread overview]
Message-ID: <20140301190114.GL19851@toaster.adamthompson.me.uk> (raw)
In-Reply-To: <20140201090007.eklhad@comcast.net>

[-- Attachment #1: Type: text/plain, Size: 2433 bytes --]

On Sat, Mar 01, 2014 at 09:00:07AM -0500, Karl Dahlke wrote:
> Well the tags are built in a growing linked list as the page is parsed,
> but at the end of parse I plop them all into an array,
> so it is easy to grab tag 243 (example), just index the array,
> because the text in your buffer actually has encoded
> 
> tag 243 {go to this link}
> 
> You don't see tag code 243 but it's there,
> and it is accessed when you go to that link.
> 
> If we want tags to continue to grow after page parse,
> new tags because of javascript creating html structures etc,
> then we want something with the dynamic power of a linked list or a tree
> but also an easy way to index like an array.
> Not sure if C++ list has this much power, or vector,
> but in C there wasn't anything, which is why I made the compromise I did.
> Anyways we might be able to forget the array and stay with the c++ list,
> and use its power to move forward.
> Create tags whenever javascript tells us to,
> and they can have parent links inside them to define the tree structure
> of forms and tables and so  on.

Yeah, I know vectors will do this for us,
with the allocation policy being implementation dependant,
but usually not too bad I think. In C I'd implement this manually using realloc
but as we're using c++ for the js stuff we can probably put the tags in a vector.
The index into the tag vector for creating the tree structure sounds kind of
nice and prevents a lot of pointers being passed around.

What this means in terms of changes I think is that we stop using the list
class (is this ok to do) and change tagarray from an array to a vector<htmlTag>
(not sure of capitalisation off the top of my head),
then use tagArray.push_back to add tags.
The parent links in the tags would be size_t variables,
and each tag would also need to maintain a vector of indices to its children
(of type vector<size_t> I think). This is a little messy,
but I'm not sure of a better implementation right now as efficient tree
traversal requires an easy way to work out what a tag's children are.
This implementation would allow that whilst keeping the efficient indexing
required for normal browsing.

The reason I'm using size_t for the parent "links"
is that they'll be indices into the tag vector which means that,
if in a realloc the whole lot gets moved,
pointers don't suddenly become invalid etc.

Cheers,
Adam.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2014-03-01 19:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-01 14:00 Karl Dahlke
2014-03-01 19:01 ` Adam Thompson [this message]
2014-03-01 19:24 Karl Dahlke
2014-03-02 13:47 ` Adam Thompson
2014-03-02 14:15 Karl Dahlke
2014-03-02 19:28 ` Adam Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140301190114.GL19851@toaster.adamthompson.me.uk \
    --to=arthompson1990@gmail.com \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    --cc=eklhad@comcast.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).