@@ -1623,6 +1623,7 @@ procedure Batch_SetFloat64Array(batch: TDSSObjectPtr; batchSize: Integer; Index:
1623
1623
doublePtr: PDouble;
1624
1624
propFlags: TPropertyFlags;
1625
1625
singleEdit: Boolean;
1626
+ allowNA: Boolean;
1626
1627
begin
1627
1628
if (batch = NIL ) or (batch^ = NIL ) or (batchSize = 0 ) then
1628
1629
Exit;
@@ -1638,23 +1639,30 @@ procedure Batch_SetFloat64Array(batch: TDSSObjectPtr; batchSize: Integer; Index:
1638
1639
]) then
1639
1640
Exit;
1640
1641
1642
+ allowNA := not (TDSSPropertySetterFlag.SkipNA in setterFlags);
1643
+
1641
1644
if (cls.PropertyType[Index] = TPropertyType.DoubleProperty) and
1642
1645
(propFlags = []) and
1643
1646
(cls.PropertyScale[Index] = 1 ) then
1644
1647
begin
1648
+ // Faster path
1645
1649
for i := 1 to batchSize do
1646
1650
begin
1647
- singleEdit := not (Flg.EditingActive in batch^.Flags);
1648
- if singleEdit then
1649
- cls.BeginEdit(batch^, False);
1651
+ // check for each element, in case the element is being edited somewhere else
1652
+ if (allowNA) or (not IsNaN(Value ^)) then
1653
+ begin
1654
+ singleEdit := not (Flg.EditingActive in batch^.Flags);
1655
+ if singleEdit then
1656
+ cls.BeginEdit(batch^, False);
1650
1657
1651
- doublePtr := PDouble(PtrUint(batch^) + propOffset);
1652
- prev := doubleptr^;
1653
- doublePtr^ := Value ^;
1654
- batch^.PropertySideEffects(Index, Round(prev), setterFlags);
1658
+ doublePtr := PDouble(PtrUint(batch^) + propOffset);
1659
+ prev := doubleptr^;
1660
+ doublePtr^ := Value ^;
1661
+ batch^.PropertySideEffects(Index, Round(prev), setterFlags);
1655
1662
1656
- if singleEdit then
1657
- cls.EndEdit(batch^, 1 );
1663
+ if singleEdit then
1664
+ cls.EndEdit(batch^, 1 );
1665
+ end ;
1658
1666
inc(batch);
1659
1667
inc(Value );
1660
1668
end ;
@@ -1663,7 +1671,9 @@ procedure Batch_SetFloat64Array(batch: TDSSObjectPtr; batchSize: Integer; Index:
1663
1671
1664
1672
for i := 1 to batchSize do
1665
1673
begin
1666
- batch^.SetDouble(Index, Value ^, setterFlags);
1674
+ if (allowNA) or (not IsNaN(Value ^)) then
1675
+ batch^.SetDouble(Index, Value ^, setterFlags);
1676
+
1667
1677
inc(batch);
1668
1678
inc(Value )
1669
1679
end ;
@@ -1678,6 +1688,7 @@ procedure Batch_SetInt32Array(batch: TDSSObjectPtr; batchSize: Integer; Index: I
1678
1688
intPtr: PInteger;
1679
1689
propFlags: TPropertyFlags;
1680
1690
singleEdit: Boolean;
1691
+ allowNA: Boolean;
1681
1692
begin
1682
1693
if (batch = NIL ) or (batch^ = NIL ) or (batchSize = 0 ) then
1683
1694
Exit;
@@ -1695,23 +1706,30 @@ procedure Batch_SetInt32Array(batch: TDSSObjectPtr; batchSize: Integer; Index: I
1695
1706
]) then
1696
1707
Exit;
1697
1708
1709
+ allowNA := not (TDSSPropertySetterFlag.SkipNA in setterFlags);
1710
+
1698
1711
if (cls.PropertyType[Index] <> TPropertyType.IntegerOnStructArrayProperty) and
1699
1712
(propFlags = []) and
1700
1713
(cls.PropertyScale[Index] = 1 ) then
1701
1714
begin
1715
+ // Faster path
1702
1716
for i := 1 to batchSize do
1703
1717
begin
1704
- singleEdit := not (Flg.EditingActive in batch^.Flags);
1705
- if singleEdit then
1706
- cls.BeginEdit(batch^, False);
1718
+ if (allowNA) or (Value ^ = $80000000 ) then
1719
+ begin
1720
+ // check for each element, in case the element is being edited somewhere else
1721
+ singleEdit := not (Flg.EditingActive in batch^.Flags);
1722
+ if singleEdit then
1723
+ cls.BeginEdit(batch^, False);
1707
1724
1708
- intPtr := PInteger(PtrUint(batch^) + propOffset);
1709
- prev := intPtr^;
1710
- intPtr^ := Value ^;
1711
- batch^.PropertySideEffects(Index, prev, setterFlags);
1725
+ intPtr := PInteger(PtrUint(batch^) + propOffset);
1726
+ prev := intPtr^;
1727
+ intPtr^ := Value ^;
1728
+ batch^.PropertySideEffects(Index, prev, setterFlags);
1712
1729
1713
- if singleEdit then
1714
- cls.EndEdit(batch^, 1 );
1730
+ if singleEdit then
1731
+ cls.EndEdit(batch^, 1 );
1732
+ end ;
1715
1733
inc(batch);
1716
1734
inc(Value );
1717
1735
end ;
@@ -1720,7 +1738,8 @@ procedure Batch_SetInt32Array(batch: TDSSObjectPtr; batchSize: Integer; Index: I
1720
1738
1721
1739
for i := 1 to batchSize do
1722
1740
begin
1723
- batch^.SetInteger(Index, Value ^, setterFlags);
1741
+ if (allowNA) or (Value ^ = $80000000 ) then
1742
+ batch^.SetInteger(Index, Value ^, setterFlags);
1724
1743
inc(batch);
1725
1744
inc(Value )
1726
1745
end ;
@@ -1732,6 +1751,7 @@ procedure Batch_SetStringArray(batch: TDSSObjectPtr; batchSize: Integer; Index:
1732
1751
// propOffset: PtrUint;
1733
1752
i: Integer;
1734
1753
// propFlags: TPropertyFlags;
1754
+ allowNA: Boolean;
1735
1755
begin
1736
1756
if (batch = NIL ) or (batch^ = NIL ) or (batchSize = 0 ) then
1737
1757
Exit;
@@ -1750,9 +1770,12 @@ procedure Batch_SetStringArray(batch: TDSSObjectPtr; batchSize: Integer; Index:
1750
1770
]) then
1751
1771
Exit;
1752
1772
1773
+ allowNA := not (TDSSPropertySetterFlag.SkipNA in setterFlags);
1774
+
1753
1775
for i := 1 to batchSize do
1754
1776
begin
1755
- batch^.SetString(Index, Value ^, setterFlags);
1777
+ if (allowNA) or (Value ^ <> NIL ) then
1778
+ batch^.SetString(Index, Value ^, setterFlags);
1756
1779
inc(batch);
1757
1780
inc(Value )
1758
1781
end ;
0 commit comments