public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: "Daniel Krügler" <daniel.kruegler@gmail.com>
Cc: libstdc++ <libstdc++@gcc.gnu.org>,
	       gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [patch] Implement ISO/IEC TS 18822 C++ File system TS
Date: Fri, 01 May 2015 18:22:00 -0000	[thread overview]
Message-ID: <20150501182223.GI3618@redhat.com> (raw)
In-Reply-To: <CAGNvRgAzHFMbsw3PLzEb4zprmGnZiLJux+vJCxY9kC-gCOhvLg@mail.gmail.com>

On 01/05/15 19:03 +0200, Daniel Krügler wrote:
>b/libstdc++-v3/src/filesystem/path.cc:
>
>- path::compare(const path& p) const noexcept:
>
>Shouldn't the implementation of this noexcept function not try to
>create copies of path objects? Couldn't _Cmpt just hold references to
>_M_pathname?

All your other comments are definitely correct and I'll make the
relevant fixes soon, but I'm not sure what you mean here, could you
clarify?

I think it would be possible to implement a path like:

  class path
  {
    using value_type = ...;
    using string_type = basic_string<value_type>;
    struct _Cmpt;
    using composite_path = pair<string_type, list<_Cmpt>>;
    using sub_path = basic_string_view<value_type>;

    variant<composite_path, sub_path> _M_data;
    enum _Type { ... } _M_type;
  };

  struct _Cmpt : path
  {
    // ...
  };

With the invariant that for all objects of type _Cmpt the variant
member holds a string_view that refers to the string_type object in
some other path.

This would reduce the memory footprint of a path object (but for the
new std::string ABI, only if there are path components longer than the
SSO small string buffer). Even with that design, paths would still
be sizeof(string_type) + sizeof(std::list<_Cmpt>) + sizeof(_Type).

Alternatively, it could be done without a variant, just adding a
string_view member to the path type, which would make it even larger,
but would simplify the implementation.

  parent reply	other threads:[~2015-05-01 18:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30 17:42 Jonathan Wakely
2015-04-30 19:33 ` Jonathan Wakely
     [not found]   ` <CAFW6PZB9WvskzrKCsNKK4s-5oXWjcwkuZGMrWbrfgJ7fpJiCXQ@mail.gmail.com>
     [not found]     ` <20150501105351.GY3618@redhat.com>
2015-05-01 19:49       ` Jonathan Wakely
2015-05-02  9:52         ` Jonathan Wakely
2015-05-08 11:43         ` Rainer Orth
2015-05-13 10:56           ` Jonathan Wakely
2015-05-01 12:45 ` Rainer Orth
2015-05-01 15:11   ` Jonathan Wakely
2015-05-01 15:14     ` Rainer Orth
2015-05-01 17:03 ` Daniel Krügler
2015-05-01 17:55   ` Jonathan Wakely
2015-05-01 18:22   ` Jonathan Wakely [this message]
2015-05-01 19:28     ` Daniel Krügler
2015-05-01 19:38       ` Jonathan Wakely
2015-05-01 20:05         ` Jonathan Wakely

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=20150501182223.GI3618@redhat.com \
    --to=jwakely@redhat.com \
    --cc=daniel.kruegler@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).