From b3a51800f74f8702f25f4278ab54dae5bfd0fc44 Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Sat, 29 Oct 2011 22:53:46 +0200 Subject: [PATCH] Removed Node.getToVar as it turned out to be a premature optimization. --- doc/doctrees/environment.pickle | Bin 12705 -> 12705 bytes doc/html/api/dyaml.node.html | 14 ---------- dyaml/node.d | 47 ++++++++++---------------------- 3 files changed, 15 insertions(+), 46 deletions(-) diff --git a/doc/doctrees/environment.pickle b/doc/doctrees/environment.pickle index 04580382336e894bb9fec318ae7e685344ebf3a6..bca770ac86fcdd1709b229fc489ffcd11d5fa8ef 100644 GIT binary patch delta 62 zcmZ3OyfAq~o4%pss}IvPGnCyOFRzw-^&(O=LkGfqyRI+86vBMn?vP;zVZJm!w|Tq% GD@FjRa~_KT delta 62 zcmZ3OyfAq~o4%pgQjcb~3}tu6%d5qfI`F*A(19>r`(9_5LYU66su^}r1wVIf-md?O F5dbLp8o&Sm diff --git a/doc/html/api/dyaml.node.html b/doc/html/api/dyaml.node.html index 69fa6bc..089e465 100644 --- a/doc/html/api/dyaml.node.html +++ b/doc/html/api/dyaml.node.html @@ -336,20 +336,6 @@ Throws:
NodeException if unable to convert to specified type, or if the value is out of range of requested type.
- -
void getToVar(T)(out T target); -
-

Write the value of the node to target. -

-

If the target type does not match node type, - conversion is attempted. - -

-Parameters:
- -
targetVariable to write to.
-Throws:
NodeException if unable to convert to specified type.
-
@property size_t length();
diff --git a/dyaml/node.d b/dyaml/node.d index a8b5685..b07b344 100644 --- a/dyaml/node.d +++ b/dyaml/node.d @@ -512,28 +512,10 @@ struct Node * the value is out of range of requested type. */ @property T get(T)() if(!is(T == const)) - { - T result; - getToVar!T(result); - return result; - } - - /** - * Write the value of the node to target. - * - * If the target type does not match node type, - * conversion is attempted. - * - * Params: target = Variable to write to. - * - * Throws: NodeException if unable to convert to specified type. - */ - void getToVar(T)(out T target) if(!is(T == const)) { if(isType!T) { - target = value_.get!T; - return; + return value_.get!T; } static if(!Value.allowed!T) @@ -544,8 +526,7 @@ struct Node auto object = as!YAMLObject; if(object.type is typeid(T)) { - target = (cast(YAMLContainer!T)object).value_; - return; + return (cast(YAMLContainer!T)object).value_; } } } @@ -554,8 +535,7 @@ struct Node //we're getting the default value. if(isMapping) { - target = this["="].as!T; - return; + return this["="].as!T; } void throwUnexpectedType() @@ -570,8 +550,7 @@ struct Node //Try to convert to string. try { - target = value_.coerce!T(); - return; + return value_.coerce!T(); } catch(VariantException e) { @@ -583,37 +562,41 @@ struct Node ///Can convert int to float. if(isInt()) { - target = to!T(value_.get!long); - return; + return to!T(value_.get!long); } else if(isFloat()) { - target = to!T(value_.get!real); - return; + return to!T(value_.get!real); + } + else + { + throwUnexpectedType(); + assert(false); } } else static if(isIntegral!T) { if(isInt()) { - long temp = value_.get!long; + const temp = value_.get!long; if(temp < T.min || temp > T.max) { throw new Error("Integer value out of range of type " ~ typeid(T).toString ~ "Value: " ~ to!string(temp), startMark_); } - target = to!T(temp); - return; + return to!T(temp); } else { throwUnexpectedType(); + assert(false); } } else { throwUnexpectedType(); + assert(false); } }