-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Removed the ++ and -- operators #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Removed the ++ and -- operators as they will no longer work with upcoming changes
Removed some C-style loops and postincrements
++i | ||
i = i.successor() | ||
i = i.successor() | ||
i = i.successor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something, but why not use i += 3
? Seems more succinct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i += 3
does not work with an Index
i = i.advancedBy(3)
could be used but maybe whoever originally wrote that code wanted to use 3 statements for whatever reason.
Ah, I was wondering why you weren't using arithmetic operators; I didn't realize |
@@ -34,7 +34,8 @@ public struct _stdlib_ShardedAtomicCounter { | |||
let hardwareConcurrency = _stdlib_getHardwareConcurrency() | |||
let count = max(8, hardwareConcurrency * hardwareConcurrency) | |||
let shards = UnsafeMutablePointer<Int>.alloc(count) | |||
for var i = 0; i != count; i++ { | |||
for i in 0...count { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 0..<count
.
Thank you! There are a lot more in the tests. |
Simplfied successor for UnsafePointer and removed unnecessary comments
Removed some post-, preincrement/decrements from test
++i | ||
++i | ||
++i | ||
i = i.advancedBy(3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the test code the exact equivalent. The test name says it is testing the successor()
function.
Please remove unrelated whitespace changes from the patch. |
} | ||
// Initialize the hole left by sliding the tail forward | ||
for j in oldTailIndex..<newTailIndex { | ||
(elements + j).initialize(newValues[i++]) | ||
(elements + j).initialize(newValues[i]) | ||
i = i.successor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i._successorInPlace()
Please compile the code and run tests before submitting -- |
Would it be better if this change was merged in at the same time as the removal of the post/pre operators? |
No, for two reasons: incremental development, and shaking out possible performance issues. |
@gribozavr Just to clarify, is that reasoning for accepted proposals? I understand this isn't the case here, but I would imagine it to be counterproductive to merge in changes when the decision has yet to be finalized. |
@katzenbaer Yes, just for accepted proposals. |
@divadretlaw I'm sorry for the delays, would you mind rebasing the PR and resolving the conflicts? |
Oh, I'm sorry, I didn't realize that there was an outstanding patch to help with this. |
# Conflicts: # stdlib/private/SwiftPrivate/ShardedAtomicCounter.swift # stdlib/public/core/ArrayCast.swift # stdlib/public/core/Collection.swift # stdlib/public/core/ContiguousArrayBuffer.swift # stdlib/public/core/StringBuffer.swift # stdlib/public/core/StringUnicodeScalarView.swift # test/1_stdlib/Builtins.swift # test/1_stdlib/Collection.swift # test/1_stdlib/ErrorType.swift # test/1_stdlib/ErrorTypeBridging.swift # test/1_stdlib/ExistentialCollection.swift # test/1_stdlib/Float.swift # test/1_stdlib/Map.swift # test/1_stdlib/Mirror.swift # test/1_stdlib/Optional.swift # test/DebugInfo/arg-debug_value.swift # test/DebugInfo/closure.swift # test/DebugInfo/for.swift # test/DebugInfo/return.swift # test/Interpreter/availability_weak_linking.swift # test/Interpreter/break_continue.swift # test/SILGen/sil_locations.swift # test/SILGen/statements.swift # test/SILGen/unreachable_code.swift # test/SILPasses/definite_init_diagnostics.swift # test/SILPasses/return.swift # test/SILPasses/switch.swift # test/SILPasses/unreachable_code.swift
Removed the ++ and -- operators
Sorry, but this change causes test failures:
I'll revert. |
@divadretlaw Could you take a look at the test failures, fix and resubmit a new PR? |
the buffer size ioctls on linux return EINVAL when it's not supported
the buffer size ioctls on linux return EINVAL when it's not supported Signed-off-by: Daniel A. Steffen <[email protected]>
Removed the ++ and -- operators as they will no longer work with
upcoming changes
https://github.com/apple/swift-evolution/blob/master/proposals/0004-remove-pre-post-inc-decrement.md