Optimise read() functions to only convert if argument is not of desired type already.

This commit is contained in:
Jürg Lehni 2011-02-13 16:05:19 +00:00
parent d67055b09b
commit 0ac19a8e82
4 changed files with 14 additions and 4 deletions
src/basic

View file

@ -278,7 +278,9 @@ Rectangle = Base.extend({
statics: {
read: function(args) {
if(args.length) {
if (args.length == 1 && args[0] instanceof Rectangle) {
return args[0];
} else if (args.length) {
var rect = new Rectangle();
rect.initialize.apply(rect, args);
return rect;