digitalmars.D.bugs - [Issue 4763] New: Few possible changes on std.stdio.File
- d-bugmail puremagic.com (43/43) Aug 29 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4763
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 puremagic.com ReportedBy: bearophile_hugs eml.cc 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: -------
Aug 29 2010