[Issue 10779] cartesianProduct leads to heavy code bloat
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Aug 8 08:13:46 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10779
bearophile_hugs at eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bearophile_hugs at eml.cc
--- Comment #1 from bearophile_hugs at eml.cc 2013-08-08 08:13:44 PDT ---
(In reply to comment #0)
> http://dpaste.dzfl.pl/45240ef6
>
> The program compiled with DMD64 D Compiler v2.063.2 has a size of 37MiB.
> It drops to 1,5MiB if you delete the usage of cartesianProduct.
The code on dpaste:
import std.conv, std.algorithm, std.range, std.stdio, std.string, std.file,
std.csv;
import std.getopt, std.path, std.bitmanip, std.exception;
Parameter[] macParameter;
Parameter[] registerParameter;
Parameter[] immediateParameter;
struct AsmTemplate
{
string template_;
string result;
string arguments;
}
struct Parameter
{
enum Type { Register, Immediate, Mac, None};
Type type;
uint val;
}
struct Test {
string template_;
Parameter[] params;
}
void generateTests(OR)(AsmTemplate ins, ref OR sink)
{
// params is a list of argument ranges with varying length, originally
// optained through a functioncall. We pad it,
// with some empty elements so we can use it in cartProd
auto params = [immediateParameter, registerParameter, macParameter, [],
[]];
foreach(tup; cartesianProduct(params[0], params[1], params[2], params[3],
params[4]))
{
auto t = Test(ins.template_, [tup[0], tup[1], tup[2], tup[3], tup[4]]);
}
}
void main()
{
auto app = appender!(Test[]);
AsmTemplate asm_;
asm_.generateTests(app);
}
Probably cartesianProduct should be rewritten from scratch, in a lower level
way.
--
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