このコード行を追加すると、コンパイル時間が10秒から3分になります。コンパイラを停止せずに複数の配列をマージするには?
var resultsArray = hashTagParticipantCodes + prefixParticipantCodes + asterixParticipantCodes + attPrefixParticipantCodes + attURLParticipantCodes
このように変更すると、コンパイル時間が通常に戻されます。
var resultsArray = hashTagParticipantCodes
resultsArray += prefixParticipantCodes
resultsArray += asterixParticipantCodes
resultsArray += attPrefixParticipantCodes
resultsArray += attURLParticipantCodes
なぜ最初の行は、私のコンパイル時間はそれほど劇的に遅くする原因と私が投稿した5ラインのソリューションよりも、これらの配列をマージするために、よりエレガントな方法はありますでしょうか?
強く関連する:http://stackoverflow.com/questions/29707622/bizarre-swift-compiler-error-expression-too-complex-on-a-string-concatenation –
@MartinRなぜこのようなことが起きたのか、確かに説明していただきありがとうございます。私はこれを言い換えて、ゆっくりとした優雅なソリューションに重点を置いていきます。 – Deco
オペランドはすべて配列ですか?私は一般的なレシピはないと思う。結果に明示的な型の注釈があると、 'var resultsArray:[YourType] = a + b + c + d + e'のようになることがあります。 http://stackoverflow.com/questions/39455123/is-force-unwrapping-a-variable-bad/39455186#comment66231724_39455186と同じ問題についての以下のコメントも参照してください。 –