Skip to content

Commit

Permalink
Fix a couple of warning and slightly improve performance (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ephread committed May 25, 2019
1 parent 12dc293 commit 21587d1
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 65 deletions.
1 change: 0 additions & 1 deletion addons/inkgd/runtime/call_stack.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ extends "res://addons/inkgd/runtime/ink_base.gd"

var PushPopType = preload("res://addons/inkgd/runtime/push_pop.gd").PushPopType
var Pointer = load("res://addons/inkgd/runtime/pointer.gd")
var InkPath = load("res://addons/inkgd/runtime/ink_path.gd")
var Ink = load("res://addons/inkgd/runtime/value.gd")

# ############################################################################ #
Expand Down
6 changes: 0 additions & 6 deletions addons/inkgd/runtime/choice_point.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

extends "res://addons/inkgd/runtime/ink_object.gd"

# ############################################################################ #
# Imports
# ############################################################################ #

var InkContainer = load("container.gd")

# ############################################################################ #

# () -> InkPath
Expand Down
6 changes: 6 additions & 0 deletions addons/inkgd/runtime/container.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

extends "res://addons/inkgd/runtime/ink_object.gd"

# ############################################################################ #
# Imports
# ############################################################################ #

var InkSearchResult = load("res://addons/inkgd/runtime/search_result.gd")

# ############################################################################ #

var name = null # String
Expand Down
8 changes: 1 addition & 7 deletions addons/inkgd/runtime/control_command.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

extends "res://addons/inkgd/runtime/ink_object.gd"

# ############################################################################ #
# Self-reference
# ############################################################################ #

var ControlCommand = weakref(load("res://addons/inkgd/runtime/control_command.gd"))

# ############################################################################ #

enum CommandType {
Expand Down Expand Up @@ -61,7 +55,7 @@ func _init(command_type = CommandType.NOT_SET):

# () -> ControlCommand
func copy():
return ControlCommand.get_ref().new(self.command_type)
return ControlCommand().get_ref().new(self.command_type)

# () -> ControlCommand
static func eval_start():
Expand Down
28 changes: 11 additions & 17 deletions addons/inkgd/runtime/ink_list.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

extends "res://addons/inkgd/runtime/ink_object.gd"

# ############################################################################ #
# Self-reference
# ############################################################################ #

var InkList = weakref(load("res://addons/inkgd/runtime/ink_list.gd"))

# ############################################################################ #
# Imports
# ############################################################################ #
Expand Down Expand Up @@ -149,7 +143,7 @@ func get_min_item():

var inverse setget , get_inverse # InkList
func get_inverse():
var list = InkList.get_ref().new()
var list = InkList().new()
if origins != null:
for origin in origins:
for serialized_item_key in origin.items:
Expand All @@ -160,7 +154,7 @@ func get_inverse():

var all setget , get_all # InkList
func get_all():
var list = InkList.get_ref().new()
var list = InkList().new()
if origins != null:
for origin in origins:
for serialized_item_key in origin.items:
Expand All @@ -170,22 +164,22 @@ func get_all():

# (InkList) -> InkList
func union(other_list):
var union = InkList.get_ref().new_with_ink_list(self)
var union = InkList().new_with_ink_list(self)
for key in other_list._dictionary:
union._dictionary[key] = other_list._dictionary[key]
return union

# (InkList) -> InkList
func intersection(other_list):
var intersection = InkList.get_ref().new()
var intersection = InkList().new()
for key in other_list._dictionary:
if self._dictionary.has(key):
intersection._dictionary[key] = other_list._dictionary[key]
return intersection

# (InkList) -> InkList
func without(list_to_remove):
var result = InkList.get_ref().new_with_ink_list(self)
var result = InkList().new_with_ink_list(self)
for key in list_to_remove._dictionary:
result._dictionary.erase(key)
return result
Expand Down Expand Up @@ -239,21 +233,21 @@ func less_than_or_equals(other_list):
func max_as_list():
if (size() > 0):
var _max_item = self.max_item
return InkList.get_ref().new_with_single_item(_max_item.key, _max_item.value)
return InkList().new_with_single_item(_max_item.key, _max_item.value)
else:
return InkList.get_ref().new()
return InkList().new()

func min_as_list():
if (size() > 0):
var _min_item = self.min_item
return InkList.get_ref().new_with_single_item(_min_item.key, _min_item.value)
return InkList().new_with_single_item(_min_item.key, _min_item.value)
else:
return InkList.get_ref().new()
return InkList().new()

# (Variant, Variant) -> InkList
func list_with_sub_range(min_bound, max_bound):
if (size() == 0):
return InkList.get_ref().new()
return InkList().new()

var ordered = self.ordered_items

Expand All @@ -272,7 +266,7 @@ func list_with_sub_range(min_bound, max_bound):
if min_bound.is_class("InkList") && min_bound.size() > 0:
max_value = max_bound.max_item.value

var sub_list = InkList.get_ref().new()
var sub_list = InkList().new()
sub_list.set_initial_origin_names(self.origin_names)
for item in ordered:
if item.value >= min_value && item.value <= max_value:
Expand Down
8 changes: 1 addition & 7 deletions addons/inkgd/runtime/ink_list_item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@

extends "res://addons/inkgd/runtime/ink_object.gd"

# ############################################################################ #
# Self-reference
# ############################################################################ #

var InkListItem = weakref(load("res://addons/inkgd/runtime/ink_list_item.gd"))

# ############################################################################ #

var origin_name = null # String
Expand Down Expand Up @@ -103,7 +97,7 @@ static func InkListItem():
#
# () -> InkListItem
func duplicate():
return InkListItem.get_ref().init_with_origin_name(origin_name, item_name)
return InkListItem().init_with_origin_name(origin_name, item_name)

# Returns a `SerializedInkListItem` representing the current
# instance. The result is intended to be used as a key inside a Map.
Expand Down
2 changes: 0 additions & 2 deletions addons/inkgd/runtime/ink_object.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ extends "res://addons/inkgd/runtime/ink_base.gd"
# Imports
# ############################################################################ #

var InkDebugMetadata = load("res://addons/inkgd/runtime/debug_metadata.gd")
var InkSearchResult = load("res://addons/inkgd/runtime/search_result.gd")
var InkPath = weakref(load("res://addons/inkgd/runtime/ink_path.gd"))

# ############################################################################ #
Expand Down
14 changes: 4 additions & 10 deletions addons/inkgd/runtime/ink_path.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

extends "res://addons/inkgd/runtime/ink_base.gd"

# ############################################################################ #
# Self-reference
# ############################################################################ #

var InkPath = weakref(load("res://addons/inkgd/runtime/ink_path.gd"))

# ############################################################################ #

const parent_id = "^"
Expand Down Expand Up @@ -101,9 +95,9 @@ func get_tail():
var tail_comps = _components.duplicate()
tail_comps.pop_front()

return InkPath.get_ref().new_with_components(tail_comps)
return InkPath().new_with_components(tail_comps)
else:
return InkPath.get_ref().self()
return InkPath().self()

var length setget , get_length # int
func get_length():
Expand Down Expand Up @@ -149,7 +143,7 @@ static func self():

# (InkPath) -> InkPath
func path_by_appending_path(path_to_append):
var p = InkPath.get_ref().new()
var p = InkPath().new()

var upward_moves = 0

Expand All @@ -175,7 +169,7 @@ func path_by_appending_path(path_to_append):

# (Component) -> InkPath
func path_by_appending_component(c):
var p = InkPath.get_ref().new()
var p = InkPath().new()
p._components = p._components + self._components
p._components.append(c)
return p
Expand Down
6 changes: 0 additions & 6 deletions addons/inkgd/runtime/native_function_call.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

extends "res://addons/inkgd/runtime/ink_object.gd"

# ############################################################################ #
# Self-reference
# ############################################################################ #

var NativeFunctionCall = weakref(load("res://addons/inkgd/runtime/native_function_call.gd"))

# ############################################################################ #
# Imports
# ############################################################################ #
Expand Down
8 changes: 1 addition & 7 deletions addons/inkgd/runtime/pointer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@

extends "res://addons/inkgd/runtime/ink_base.gd"

# ############################################################################ #
# Self-reference
# ############################################################################ #

var Pointer = weakref(load("res://addons/inkgd/runtime/pointer.gd"))

# ############################################################################ #
# Imports
# ############################################################################ #
Expand Down Expand Up @@ -94,7 +88,7 @@ func get_class():

# () -> Pointer
func duplicate():
return Pointer.get_ref().new(container, index)
return Pointer().new(container, index)

static func Pointer():
return load("res://addons/inkgd/runtime/pointer.gd")
2 changes: 0 additions & 2 deletions addons/inkgd/runtime/story_state.gd
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ var Ink = load("res://addons/inkgd/runtime/value.gd")
var ControlCommand = load("res://addons/inkgd/runtime/control_command.gd")
var SimpleJson = load("res://addons/inkgd/runtime/simple_json.gd")

var Story = weakref(load("res://addons/inkgd/runtime/story.gd"))

# ############################################################################ #

const INK_SAVE_STATE_VERSION = 8
Expand Down
7 changes: 7 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ boot_splash/fullsize=false
boot_splash/bg_color=Color( 0.929412, 0.898039, 0.854902, 1 )
config/icon="res://icon.png"

[debug]

gdscript/completion/autocomplete_setters_and_getters=true
gdscript/warnings/unused_variable=false
gdscript/warnings/unused_class_variable=false
gdscript/warnings/unused_argument=false

[display]

window/size/width=1920
Expand Down

0 comments on commit 21587d1

Please sign in to comment.