Skip to content

Commit ad879ce

Browse files
committed
Limit history to 30 items
Clear the first item when the history is full
1 parent b63db44 commit ad879ce

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

SubnetCalcAppDelegate.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
1717
static let defaultIP: String = "10.0.0.0"
1818
static let defaultIPv6Mask: String = "64"
1919
static let defaultIPv6to4Mask: Int = 96
20+
static let maxAddrHistory: Int = 30
2021
static let BUFFER_LINES:Int = 200000000
2122
static let NETWORK_BITS_MIN_CLASSLESS:Int = 1
2223
static let NETWORK_BITS_MIN:Int = 8
@@ -1436,6 +1437,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
14361437
if ((sender as? NSTextField)?.stringValue) != nil {
14371438
if (sender.stringValue != "") {
14381439
if (addrField.indexOfItem(withObjectValue: sender.stringValue!) == NSNotFound) {
1440+
if (addrField.numberOfItems == Constants.maxAddrHistory) {
1441+
addrField.removeItem(at: 0)
1442+
}
14391443
addrField.addItem(withObjectValue: sender.stringValue!)
14401444
}
14411445
self.calc(sender)

0 commit comments

Comments
 (0)