[Issue 4763] New: Few possible changes on std.stdio.File
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 29 16:57:35 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4763
Summary: Few possible changes on std.stdio.File
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2010-08-29 16:57:23 PDT ---
This is not a bug report, it's a list of three possible small changes to the
code/API of std.stdio.File.
Here Andrei says that the std.stdio.File.open() method is useful for
performance:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=116278
Indeed inside File.this() there is an allocation, that open() may sometimes
save if File.Impl.refs is 1. But open() contains:
auto another = File(name, stdioOpenmode);
That calls File.this(), so at a first sight it seems that open() performs the
allocation anyway (if I am wrong then please ignore this).
Generally it's positive to minimize APIs. You may write:
auto f = File(...)
f = File(...)
Instead of:
auto f = File(...)
f.open(...)
----------------------
According to D specs on the site, inner structs contain an extra scope pointer,
so this may be better:
private static struct Impl {
See also bug 4087
----------------------
Given the presence of opAssign, I presume this code, inside open():
auto another = File(name, stdioOpenmode);
swap(this, another);
May be written just as:
this = File(name, stdioOpenmode);
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list