mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Swift SIL: make Function.name and GlobalVariable.name return a StringRef and not a String
and introduce the StringRef struct. It's more efficient. Also, rename the `HasName` protocol to `HasShortDescription`, which introduces the new requirement `shortDescription`. This is need because `name` now has `StringRef` type and not `String` anymore
This commit is contained in:
@@ -13,11 +13,11 @@
|
||||
import Basic
|
||||
import SILBridging
|
||||
|
||||
final public class Function : CustomStringConvertible, HasName {
|
||||
final public class Function : CustomStringConvertible, HasShortDescription {
|
||||
public private(set) var effects = FunctionEffects()
|
||||
|
||||
public var name: String {
|
||||
return SILFunction_getName(bridged).string
|
||||
public var name: StringRef {
|
||||
return StringRef(bridged: SILFunction_getName(bridged))
|
||||
}
|
||||
|
||||
final public var description: String {
|
||||
@@ -25,6 +25,8 @@ final public class Function : CustomStringConvertible, HasName {
|
||||
return String(cString: s.c_str())
|
||||
}
|
||||
|
||||
public var shortDescription: String { name.string }
|
||||
|
||||
public var entryBlock: BasicBlock {
|
||||
SILFunction_firstBlock(bridged).block!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user