You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ Shallow cloning (clone only same object, not objects that object relate to)
44
44
45
45
## Installation
46
46
47
-
Trought nuget:
47
+
Through nuget:
48
48
```
49
49
Install-Package DeepCloner
50
50
```
@@ -54,7 +54,7 @@ Trought nuget:
54
54
You can use deep clone of objects for a lot of situations, e.g.:
55
55
* Emulation of external service or _deserialization elimination_ (e.g. in Unit Testing). When code has received object from external source, code can change it (because object for code is *own*).
56
56
* ReadOnly object replace. Instead of wrapping your object to readonly object, you can clone object and target code can do anything with it without any restriction.
57
-
* Caching. You can cache data locally and want to ensurce that cached object hadntt been changed by other code
57
+
* Caching. You can cache data locally and want to ensurce that cached object hadn't been changed by other code
58
58
59
59
You can use shallow clone as fast, light version of deep clone (if your situation allows that). Main difference between deep and shallow clone in code below:
60
60
```
@@ -85,11 +85,11 @@ Tables below, just for information. Simple object with some fields ara cloned mu
85
85
86
86
Method | Time (in ms) | Comments
87
87
---|---|---
88
-
Manual | 12 | You should manually realize cloning. It requires a lot of work and can cause copy-paste errors, but it is fastest variant
89
-
DeepClone / Unsafe | 196 | This variant is 20 times slower than manual, but clones any object without preparation
90
-
DeepClone / Safe | 217 | Safe variant based on on expressions
91
-
[CloneExtensions](https://github.com/MarcinJuraszek/CloneExtensions) | 407ms | Implementation of cloning objects on expression trees.
92
-
BinaryFormatter | 10000 | Another way of deep object cloning through serializing/deserializing object. Instead of Json serializers - it maintains full graph of serializing objects and also do not call any method for cloning object. But due serious overhead, this variant is very slow
88
+
Manual | 13 | You should manually realize cloning. It requires a lot of work and can cause copy-paste errors, but it is fastest variant
89
+
DeepClone / Unsafe | 331 | This variant is really slower than manual, but clones any object without preparation
90
+
DeepClone / Safe | 411 | Safe variant based on on expressions
91
+
[CloneExtensions](https://github.com/MarcinJuraszek/CloneExtensions) | 560 | Implementation of cloning objects on expression trees.
92
+
BinaryFormatter | 15000 | Another way of deep object cloning through serializing/deserializing object. Instead of Json serializers - it maintains full graph of serializing objects and also do not call any method for cloning object. But due serious overhead, this variant is very slow
93
93
94
94
**Shallow cloning**
95
95
Shallow cloning is usually faster, because we no need to calculate references and clone additional objects.
0 commit comments