title: Swift When saving constants what's the performance differences between Enum.rawValue and static constant property?
body: <p>When saving constants, for example string keys, what's the performance differences between using enum's rawValue and using a static constant property?
  Are they effectively the same to the compiler when the full module optimization is turned on?</p>
  <p>For example,</p>
  <pre class="lang-swift prettyprint-override"><code>enum Schema: String {
      case createdAt = &quot;createdAt&quot;
  }
  
  // Here As namespace only, similarly if we use struct/protocol.
  enum Schema { 
      static let createdAt = &quot;createdAt&quot;
  }
  </code></pre>
  <p>Further, if we add a prefix, will they still be identical to the compiler?</p>
  <pre class="lang-swift prettyprint-override"><code>enum DynamicSchema: String {
      case createdAt = &quot;createdAt&quot;
  
      var prefixed: String { 
          &quot;com.blah.bleb.&quot; + self
      }
  }
  
  enum StaticSchema { 
      static let prefixString = &quot;com.blah.bleb.&quot;
      
      static let createdAt = &quot;createdAt&quot;
  }
  
  // For example,
  UserDefaults.standard.object(forKey: DynamicSchema.createdAt.prefixed)
  
  UserDefaults.standard.object(forKey: StaticSchema.prefixString + StaticSchema.createdAt)
  </code></pre>