@@ -114,13 +114,11 @@ library LibClone {
114
114
mstore (0x14 , implementation)
115
115
mstore (0x00 , 0x602c3d8160093d39f33d3d3d3d363d3d37363d73 )
116
116
instance := create (value, 0x0c , 0x35 )
117
- // If `instance` is zero, revert.
118
117
if iszero (instance) {
119
118
mstore (0x00 , 0x30116425 ) // `DeploymentFailed()`.
120
119
revert (0x1c , 0x04 )
121
120
}
122
- // Restore the part of the free memory pointer that has been overwritten.
123
- mstore (0x21 , 0 )
121
+ mstore (0x21 , 0 ) // Restore the overwritten part of the free memory pointer.
124
122
}
125
123
}
126
124
@@ -143,13 +141,11 @@ library LibClone {
143
141
mstore (0x14 , implementation)
144
142
mstore (0x00 , 0x602c3d8160093d39f33d3d3d3d363d3d37363d73 )
145
143
instance := create2 (value, 0x0c , 0x35 , salt)
146
- // If `instance` is zero, revert.
147
144
if iszero (instance) {
148
145
mstore (0x00 , 0x30116425 ) // `DeploymentFailed()`.
149
146
revert (0x1c , 0x04 )
150
147
}
151
- // Restore the part of the free memory pointer that has been overwritten.
152
- mstore (0x21 , 0 )
148
+ mstore (0x21 , 0 ) // Restore the overwritten part of the free memory pointer.
153
149
}
154
150
}
155
151
@@ -162,8 +158,7 @@ library LibClone {
162
158
mstore (0x14 , implementation)
163
159
mstore (0x00 , 0x602c3d8160093d39f33d3d3d3d363d3d37363d73 )
164
160
hash := keccak256 (0x0c , 0x35 )
165
- // Restore the part of the free memory pointer that has been overwritten.
166
- mstore (0x21 , 0 )
161
+ mstore (0x21 , 0 ) // Restore the overwritten part of the free memory pointer.
167
162
}
168
163
}
169
164
@@ -257,13 +252,11 @@ library LibClone {
257
252
mstore (0x14 , implementation) // 20
258
253
mstore (0x00 , 0x602d5f8160095f39f35f5f365f5f37365f73 ) // 9 + 9
259
254
instance := create (value, 0x0e , 0x36 )
260
- // If `instance` is zero, revert.
261
255
if iszero (instance) {
262
256
mstore (0x00 , 0x30116425 ) // `DeploymentFailed()`.
263
257
revert (0x1c , 0x04 )
264
258
}
265
- // Restore the part of the free memory pointer that has been overwritten.
266
- mstore (0x24 , 0 )
259
+ mstore (0x24 , 0 ) // Restore the overwritten part of the free memory pointer.
267
260
}
268
261
}
269
262
@@ -286,13 +279,11 @@ library LibClone {
286
279
mstore (0x14 , implementation) // 20
287
280
mstore (0x00 , 0x602d5f8160095f39f35f5f365f5f37365f73 ) // 9 + 9
288
281
instance := create2 (value, 0x0e , 0x36 , salt)
289
- // If `instance` is zero, revert.
290
282
if iszero (instance) {
291
283
mstore (0x00 , 0x30116425 ) // `DeploymentFailed()`.
292
284
revert (0x1c , 0x04 )
293
285
}
294
- // Restore the part of the free memory pointer that has been overwritten.
295
- mstore (0x24 , 0 )
286
+ mstore (0x24 , 0 ) // Restore the overwritten part of the free memory pointer.
296
287
}
297
288
}
298
289
@@ -305,8 +296,7 @@ library LibClone {
305
296
mstore (0x14 , implementation) // 20
306
297
mstore (0x00 , 0x602d5f8160095f39f35f5f365f5f37365f73 ) // 9 + 9
307
298
hash := keccak256 (0x0e , 0x36 )
308
- // Restore the part of the free memory pointer that has been overwritten.
309
- mstore (0x24 , 0 )
299
+ mstore (0x24 , 0 ) // Restore the overwritten part of the free memory pointer.
310
300
}
311
301
}
312
302
@@ -431,10 +421,9 @@ library LibClone {
431
421
* f3 | RETURN | | [0..rds): returndata |
432
422
* ---------------------------------------------------------------------------------------------------+
433
423
*/
434
- // Write the bytecode before the data.
435
- mstore (data, 0x5af43d3d93803e606057fd5bf3 )
436
- // Write the address of the implementation.
437
- mstore (sub (data, 0x0d ), implementation)
424
+
425
+ mstore (data, 0x5af43d3d93803e606057fd5bf3 ) // Write the bytecode before the data.
426
+ mstore (sub (data, 0x0d ), implementation) // Write the address of the implementation.
438
427
// Write the rest of the bytecode.
439
428
mstore (
440
429
sub (data, 0x21 ),
@@ -452,10 +441,7 @@ library LibClone {
452
441
)
453
442
mstore (dataEnd, shl (0xf0 , extraLength))
454
443
455
- // Create the instance.
456
444
instance := create (value, sub (data, 0x4c ), add (extraLength, 0x6c ))
457
-
458
- // If `instance` is zero, revert.
459
445
if iszero (instance) {
460
446
mstore (0x00 , 0x30116425 ) // `DeploymentFailed()`.
461
447
revert (0x1c , 0x04 )
@@ -499,10 +485,8 @@ library LibClone {
499
485
// +2 bytes for telling how much data there is appended to the call.
500
486
let extraLength := add (dataLength, 2 )
501
487
502
- // Write the bytecode before the data.
503
- mstore (data, 0x5af43d3d93803e606057fd5bf3 )
504
- // Write the address of the implementation.
505
- mstore (sub (data, 0x0d ), implementation)
488
+ mstore (data, 0x5af43d3d93803e606057fd5bf3 ) // Write the bytecode before the data.
489
+ mstore (sub (data, 0x0d ), implementation) // Write the address of the implementation.
506
490
// Write the rest of the bytecode.
507
491
mstore (
508
492
sub (data, 0x21 ),
@@ -520,10 +504,7 @@ library LibClone {
520
504
)
521
505
mstore (dataEnd, shl (0xf0 , extraLength))
522
506
523
- // Create the instance.
524
507
instance := create2 (value, sub (data, 0x4c ), add (extraLength, 0x6c ), salt)
525
-
526
- // If `instance` is zero, revert.
527
508
if iszero (instance) {
528
509
mstore (0x00 , 0x30116425 ) // `DeploymentFailed()`.
529
510
revert (0x1c , 0x04 )
@@ -581,7 +562,6 @@ library LibClone {
581
562
)
582
563
mstore (dataEnd, shl (0xf0 , extraLength))
583
564
584
- // Compute and store the bytecode hash.
585
565
hash := keccak256 (sub (data, 0x4c ), add (extraLength, 0x6c ))
586
566
587
567
// Restore the overwritten memory surrounding `data`.
@@ -694,7 +674,6 @@ library LibClone {
694
674
mstore (0x1e , implementation)
695
675
mstore (0x0a , 0x603d3d8160223d3973 )
696
676
instance := create (value, 0x21 , 0x5f )
697
- // If `instance` is zero, revert.
698
677
if iszero (instance) {
699
678
mstore (0x00 , 0x30116425 ) // `DeploymentFailed()`.
700
679
revert (0x1c , 0x04 )
@@ -726,7 +705,6 @@ library LibClone {
726
705
mstore (0x1e , implementation)
727
706
mstore (0x0a , 0x603d3d8160223d3973 )
728
707
instance := create2 (value, 0x21 , 0x5f , salt)
729
- // If `instance` is zero, revert.
730
708
if iszero (instance) {
731
709
mstore (0x00 , 0x30116425 ) // `DeploymentFailed()`.
732
710
revert (0x1c , 0x04 )
@@ -785,8 +763,7 @@ library LibClone {
785
763
mstore (0x01 , shl (96 , deployer))
786
764
mstore (0x15 , salt)
787
765
predicted := keccak256 (0x00 , 0x55 )
788
- // Restore the part of the free memory pointer that has been overwritten.
789
- mstore (0x35 , 0 )
766
+ mstore (0x35 , 0 ) // Restore the overwritten part of the free memory pointer.
790
767
}
791
768
}
792
769
0 commit comments