summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/kernel')
-rwxr-xr-xpkg/sentry/kernel/epoll/epoll_list.go33
-rwxr-xr-xpkg/sentry/kernel/futex/waiter_list.go33
-rwxr-xr-xpkg/sentry/kernel/pending_signals_list.go33
-rwxr-xr-xpkg/sentry/kernel/process_group_list.go33
-rwxr-xr-xpkg/sentry/kernel/semaphore/waiter_list.go33
-rwxr-xr-xpkg/sentry/kernel/session_list.go33
-rwxr-xr-xpkg/sentry/kernel/socket_list.go33
-rwxr-xr-xpkg/sentry/kernel/task_list.go33
8 files changed, 168 insertions, 96 deletions
diff --git a/pkg/sentry/kernel/epoll/epoll_list.go b/pkg/sentry/kernel/epoll/epoll_list.go
index 94d5c9e57..5ac854e38 100755
--- a/pkg/sentry/kernel/epoll/epoll_list.go
+++ b/pkg/sentry/kernel/epoll/epoll_list.go
@@ -54,8 +54,9 @@ func (l *pollEntryList) Back() *pollEntry {
// PushFront inserts the element e at the front of list l.
func (l *pollEntryList) PushFront(e *pollEntry) {
- pollEntryElementMapper{}.linkerFor(e).SetNext(l.head)
- pollEntryElementMapper{}.linkerFor(e).SetPrev(nil)
+ linker := pollEntryElementMapper{}.linkerFor(e)
+ linker.SetNext(l.head)
+ linker.SetPrev(nil)
if l.head != nil {
pollEntryElementMapper{}.linkerFor(l.head).SetPrev(e)
@@ -68,8 +69,9 @@ func (l *pollEntryList) PushFront(e *pollEntry) {
// PushBack inserts the element e at the back of list l.
func (l *pollEntryList) PushBack(e *pollEntry) {
- pollEntryElementMapper{}.linkerFor(e).SetNext(nil)
- pollEntryElementMapper{}.linkerFor(e).SetPrev(l.tail)
+ linker := pollEntryElementMapper{}.linkerFor(e)
+ linker.SetNext(nil)
+ linker.SetPrev(l.tail)
if l.tail != nil {
pollEntryElementMapper{}.linkerFor(l.tail).SetNext(e)
@@ -98,10 +100,14 @@ func (l *pollEntryList) PushBackList(m *pollEntryList) {
// InsertAfter inserts e after b.
func (l *pollEntryList) InsertAfter(b, e *pollEntry) {
- a := pollEntryElementMapper{}.linkerFor(b).Next()
- pollEntryElementMapper{}.linkerFor(e).SetNext(a)
- pollEntryElementMapper{}.linkerFor(e).SetPrev(b)
- pollEntryElementMapper{}.linkerFor(b).SetNext(e)
+ bLinker := pollEntryElementMapper{}.linkerFor(b)
+ eLinker := pollEntryElementMapper{}.linkerFor(e)
+
+ a := bLinker.Next()
+
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ bLinker.SetNext(e)
if a != nil {
pollEntryElementMapper{}.linkerFor(a).SetPrev(e)
@@ -112,10 +118,13 @@ func (l *pollEntryList) InsertAfter(b, e *pollEntry) {
// InsertBefore inserts e before a.
func (l *pollEntryList) InsertBefore(a, e *pollEntry) {
- b := pollEntryElementMapper{}.linkerFor(a).Prev()
- pollEntryElementMapper{}.linkerFor(e).SetNext(a)
- pollEntryElementMapper{}.linkerFor(e).SetPrev(b)
- pollEntryElementMapper{}.linkerFor(a).SetPrev(e)
+ aLinker := pollEntryElementMapper{}.linkerFor(a)
+ eLinker := pollEntryElementMapper{}.linkerFor(e)
+
+ b := aLinker.Prev()
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ aLinker.SetPrev(e)
if b != nil {
pollEntryElementMapper{}.linkerFor(b).SetNext(e)
diff --git a/pkg/sentry/kernel/futex/waiter_list.go b/pkg/sentry/kernel/futex/waiter_list.go
index cca5c4721..b6baa1b5b 100755
--- a/pkg/sentry/kernel/futex/waiter_list.go
+++ b/pkg/sentry/kernel/futex/waiter_list.go
@@ -54,8 +54,9 @@ func (l *waiterList) Back() *Waiter {
// PushFront inserts the element e at the front of list l.
func (l *waiterList) PushFront(e *Waiter) {
- waiterElementMapper{}.linkerFor(e).SetNext(l.head)
- waiterElementMapper{}.linkerFor(e).SetPrev(nil)
+ linker := waiterElementMapper{}.linkerFor(e)
+ linker.SetNext(l.head)
+ linker.SetPrev(nil)
if l.head != nil {
waiterElementMapper{}.linkerFor(l.head).SetPrev(e)
@@ -68,8 +69,9 @@ func (l *waiterList) PushFront(e *Waiter) {
// PushBack inserts the element e at the back of list l.
func (l *waiterList) PushBack(e *Waiter) {
- waiterElementMapper{}.linkerFor(e).SetNext(nil)
- waiterElementMapper{}.linkerFor(e).SetPrev(l.tail)
+ linker := waiterElementMapper{}.linkerFor(e)
+ linker.SetNext(nil)
+ linker.SetPrev(l.tail)
if l.tail != nil {
waiterElementMapper{}.linkerFor(l.tail).SetNext(e)
@@ -98,10 +100,14 @@ func (l *waiterList) PushBackList(m *waiterList) {
// InsertAfter inserts e after b.
func (l *waiterList) InsertAfter(b, e *Waiter) {
- a := waiterElementMapper{}.linkerFor(b).Next()
- waiterElementMapper{}.linkerFor(e).SetNext(a)
- waiterElementMapper{}.linkerFor(e).SetPrev(b)
- waiterElementMapper{}.linkerFor(b).SetNext(e)
+ bLinker := waiterElementMapper{}.linkerFor(b)
+ eLinker := waiterElementMapper{}.linkerFor(e)
+
+ a := bLinker.Next()
+
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ bLinker.SetNext(e)
if a != nil {
waiterElementMapper{}.linkerFor(a).SetPrev(e)
@@ -112,10 +118,13 @@ func (l *waiterList) InsertAfter(b, e *Waiter) {
// InsertBefore inserts e before a.
func (l *waiterList) InsertBefore(a, e *Waiter) {
- b := waiterElementMapper{}.linkerFor(a).Prev()
- waiterElementMapper{}.linkerFor(e).SetNext(a)
- waiterElementMapper{}.linkerFor(e).SetPrev(b)
- waiterElementMapper{}.linkerFor(a).SetPrev(e)
+ aLinker := waiterElementMapper{}.linkerFor(a)
+ eLinker := waiterElementMapper{}.linkerFor(e)
+
+ b := aLinker.Prev()
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ aLinker.SetPrev(e)
if b != nil {
waiterElementMapper{}.linkerFor(b).SetNext(e)
diff --git a/pkg/sentry/kernel/pending_signals_list.go b/pkg/sentry/kernel/pending_signals_list.go
index a3499371a..26b9ffd98 100755
--- a/pkg/sentry/kernel/pending_signals_list.go
+++ b/pkg/sentry/kernel/pending_signals_list.go
@@ -54,8 +54,9 @@ func (l *pendingSignalList) Back() *pendingSignal {
// PushFront inserts the element e at the front of list l.
func (l *pendingSignalList) PushFront(e *pendingSignal) {
- pendingSignalElementMapper{}.linkerFor(e).SetNext(l.head)
- pendingSignalElementMapper{}.linkerFor(e).SetPrev(nil)
+ linker := pendingSignalElementMapper{}.linkerFor(e)
+ linker.SetNext(l.head)
+ linker.SetPrev(nil)
if l.head != nil {
pendingSignalElementMapper{}.linkerFor(l.head).SetPrev(e)
@@ -68,8 +69,9 @@ func (l *pendingSignalList) PushFront(e *pendingSignal) {
// PushBack inserts the element e at the back of list l.
func (l *pendingSignalList) PushBack(e *pendingSignal) {
- pendingSignalElementMapper{}.linkerFor(e).SetNext(nil)
- pendingSignalElementMapper{}.linkerFor(e).SetPrev(l.tail)
+ linker := pendingSignalElementMapper{}.linkerFor(e)
+ linker.SetNext(nil)
+ linker.SetPrev(l.tail)
if l.tail != nil {
pendingSignalElementMapper{}.linkerFor(l.tail).SetNext(e)
@@ -98,10 +100,14 @@ func (l *pendingSignalList) PushBackList(m *pendingSignalList) {
// InsertAfter inserts e after b.
func (l *pendingSignalList) InsertAfter(b, e *pendingSignal) {
- a := pendingSignalElementMapper{}.linkerFor(b).Next()
- pendingSignalElementMapper{}.linkerFor(e).SetNext(a)
- pendingSignalElementMapper{}.linkerFor(e).SetPrev(b)
- pendingSignalElementMapper{}.linkerFor(b).SetNext(e)
+ bLinker := pendingSignalElementMapper{}.linkerFor(b)
+ eLinker := pendingSignalElementMapper{}.linkerFor(e)
+
+ a := bLinker.Next()
+
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ bLinker.SetNext(e)
if a != nil {
pendingSignalElementMapper{}.linkerFor(a).SetPrev(e)
@@ -112,10 +118,13 @@ func (l *pendingSignalList) InsertAfter(b, e *pendingSignal) {
// InsertBefore inserts e before a.
func (l *pendingSignalList) InsertBefore(a, e *pendingSignal) {
- b := pendingSignalElementMapper{}.linkerFor(a).Prev()
- pendingSignalElementMapper{}.linkerFor(e).SetNext(a)
- pendingSignalElementMapper{}.linkerFor(e).SetPrev(b)
- pendingSignalElementMapper{}.linkerFor(a).SetPrev(e)
+ aLinker := pendingSignalElementMapper{}.linkerFor(a)
+ eLinker := pendingSignalElementMapper{}.linkerFor(e)
+
+ b := aLinker.Prev()
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ aLinker.SetPrev(e)
if b != nil {
pendingSignalElementMapper{}.linkerFor(b).SetNext(e)
diff --git a/pkg/sentry/kernel/process_group_list.go b/pkg/sentry/kernel/process_group_list.go
index 853145237..2c5363c69 100755
--- a/pkg/sentry/kernel/process_group_list.go
+++ b/pkg/sentry/kernel/process_group_list.go
@@ -54,8 +54,9 @@ func (l *processGroupList) Back() *ProcessGroup {
// PushFront inserts the element e at the front of list l.
func (l *processGroupList) PushFront(e *ProcessGroup) {
- processGroupElementMapper{}.linkerFor(e).SetNext(l.head)
- processGroupElementMapper{}.linkerFor(e).SetPrev(nil)
+ linker := processGroupElementMapper{}.linkerFor(e)
+ linker.SetNext(l.head)
+ linker.SetPrev(nil)
if l.head != nil {
processGroupElementMapper{}.linkerFor(l.head).SetPrev(e)
@@ -68,8 +69,9 @@ func (l *processGroupList) PushFront(e *ProcessGroup) {
// PushBack inserts the element e at the back of list l.
func (l *processGroupList) PushBack(e *ProcessGroup) {
- processGroupElementMapper{}.linkerFor(e).SetNext(nil)
- processGroupElementMapper{}.linkerFor(e).SetPrev(l.tail)
+ linker := processGroupElementMapper{}.linkerFor(e)
+ linker.SetNext(nil)
+ linker.SetPrev(l.tail)
if l.tail != nil {
processGroupElementMapper{}.linkerFor(l.tail).SetNext(e)
@@ -98,10 +100,14 @@ func (l *processGroupList) PushBackList(m *processGroupList) {
// InsertAfter inserts e after b.
func (l *processGroupList) InsertAfter(b, e *ProcessGroup) {
- a := processGroupElementMapper{}.linkerFor(b).Next()
- processGroupElementMapper{}.linkerFor(e).SetNext(a)
- processGroupElementMapper{}.linkerFor(e).SetPrev(b)
- processGroupElementMapper{}.linkerFor(b).SetNext(e)
+ bLinker := processGroupElementMapper{}.linkerFor(b)
+ eLinker := processGroupElementMapper{}.linkerFor(e)
+
+ a := bLinker.Next()
+
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ bLinker.SetNext(e)
if a != nil {
processGroupElementMapper{}.linkerFor(a).SetPrev(e)
@@ -112,10 +118,13 @@ func (l *processGroupList) InsertAfter(b, e *ProcessGroup) {
// InsertBefore inserts e before a.
func (l *processGroupList) InsertBefore(a, e *ProcessGroup) {
- b := processGroupElementMapper{}.linkerFor(a).Prev()
- processGroupElementMapper{}.linkerFor(e).SetNext(a)
- processGroupElementMapper{}.linkerFor(e).SetPrev(b)
- processGroupElementMapper{}.linkerFor(a).SetPrev(e)
+ aLinker := processGroupElementMapper{}.linkerFor(a)
+ eLinker := processGroupElementMapper{}.linkerFor(e)
+
+ b := aLinker.Prev()
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ aLinker.SetPrev(e)
if b != nil {
processGroupElementMapper{}.linkerFor(b).SetNext(e)
diff --git a/pkg/sentry/kernel/semaphore/waiter_list.go b/pkg/sentry/kernel/semaphore/waiter_list.go
index 33e29fb55..78d86900a 100755
--- a/pkg/sentry/kernel/semaphore/waiter_list.go
+++ b/pkg/sentry/kernel/semaphore/waiter_list.go
@@ -54,8 +54,9 @@ func (l *waiterList) Back() *waiter {
// PushFront inserts the element e at the front of list l.
func (l *waiterList) PushFront(e *waiter) {
- waiterElementMapper{}.linkerFor(e).SetNext(l.head)
- waiterElementMapper{}.linkerFor(e).SetPrev(nil)
+ linker := waiterElementMapper{}.linkerFor(e)
+ linker.SetNext(l.head)
+ linker.SetPrev(nil)
if l.head != nil {
waiterElementMapper{}.linkerFor(l.head).SetPrev(e)
@@ -68,8 +69,9 @@ func (l *waiterList) PushFront(e *waiter) {
// PushBack inserts the element e at the back of list l.
func (l *waiterList) PushBack(e *waiter) {
- waiterElementMapper{}.linkerFor(e).SetNext(nil)
- waiterElementMapper{}.linkerFor(e).SetPrev(l.tail)
+ linker := waiterElementMapper{}.linkerFor(e)
+ linker.SetNext(nil)
+ linker.SetPrev(l.tail)
if l.tail != nil {
waiterElementMapper{}.linkerFor(l.tail).SetNext(e)
@@ -98,10 +100,14 @@ func (l *waiterList) PushBackList(m *waiterList) {
// InsertAfter inserts e after b.
func (l *waiterList) InsertAfter(b, e *waiter) {
- a := waiterElementMapper{}.linkerFor(b).Next()
- waiterElementMapper{}.linkerFor(e).SetNext(a)
- waiterElementMapper{}.linkerFor(e).SetPrev(b)
- waiterElementMapper{}.linkerFor(b).SetNext(e)
+ bLinker := waiterElementMapper{}.linkerFor(b)
+ eLinker := waiterElementMapper{}.linkerFor(e)
+
+ a := bLinker.Next()
+
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ bLinker.SetNext(e)
if a != nil {
waiterElementMapper{}.linkerFor(a).SetPrev(e)
@@ -112,10 +118,13 @@ func (l *waiterList) InsertAfter(b, e *waiter) {
// InsertBefore inserts e before a.
func (l *waiterList) InsertBefore(a, e *waiter) {
- b := waiterElementMapper{}.linkerFor(a).Prev()
- waiterElementMapper{}.linkerFor(e).SetNext(a)
- waiterElementMapper{}.linkerFor(e).SetPrev(b)
- waiterElementMapper{}.linkerFor(a).SetPrev(e)
+ aLinker := waiterElementMapper{}.linkerFor(a)
+ eLinker := waiterElementMapper{}.linkerFor(e)
+
+ b := aLinker.Prev()
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ aLinker.SetPrev(e)
if b != nil {
waiterElementMapper{}.linkerFor(b).SetNext(e)
diff --git a/pkg/sentry/kernel/session_list.go b/pkg/sentry/kernel/session_list.go
index 9ba27b164..e65688f53 100755
--- a/pkg/sentry/kernel/session_list.go
+++ b/pkg/sentry/kernel/session_list.go
@@ -54,8 +54,9 @@ func (l *sessionList) Back() *Session {
// PushFront inserts the element e at the front of list l.
func (l *sessionList) PushFront(e *Session) {
- sessionElementMapper{}.linkerFor(e).SetNext(l.head)
- sessionElementMapper{}.linkerFor(e).SetPrev(nil)
+ linker := sessionElementMapper{}.linkerFor(e)
+ linker.SetNext(l.head)
+ linker.SetPrev(nil)
if l.head != nil {
sessionElementMapper{}.linkerFor(l.head).SetPrev(e)
@@ -68,8 +69,9 @@ func (l *sessionList) PushFront(e *Session) {
// PushBack inserts the element e at the back of list l.
func (l *sessionList) PushBack(e *Session) {
- sessionElementMapper{}.linkerFor(e).SetNext(nil)
- sessionElementMapper{}.linkerFor(e).SetPrev(l.tail)
+ linker := sessionElementMapper{}.linkerFor(e)
+ linker.SetNext(nil)
+ linker.SetPrev(l.tail)
if l.tail != nil {
sessionElementMapper{}.linkerFor(l.tail).SetNext(e)
@@ -98,10 +100,14 @@ func (l *sessionList) PushBackList(m *sessionList) {
// InsertAfter inserts e after b.
func (l *sessionList) InsertAfter(b, e *Session) {
- a := sessionElementMapper{}.linkerFor(b).Next()
- sessionElementMapper{}.linkerFor(e).SetNext(a)
- sessionElementMapper{}.linkerFor(e).SetPrev(b)
- sessionElementMapper{}.linkerFor(b).SetNext(e)
+ bLinker := sessionElementMapper{}.linkerFor(b)
+ eLinker := sessionElementMapper{}.linkerFor(e)
+
+ a := bLinker.Next()
+
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ bLinker.SetNext(e)
if a != nil {
sessionElementMapper{}.linkerFor(a).SetPrev(e)
@@ -112,10 +118,13 @@ func (l *sessionList) InsertAfter(b, e *Session) {
// InsertBefore inserts e before a.
func (l *sessionList) InsertBefore(a, e *Session) {
- b := sessionElementMapper{}.linkerFor(a).Prev()
- sessionElementMapper{}.linkerFor(e).SetNext(a)
- sessionElementMapper{}.linkerFor(e).SetPrev(b)
- sessionElementMapper{}.linkerFor(a).SetPrev(e)
+ aLinker := sessionElementMapper{}.linkerFor(a)
+ eLinker := sessionElementMapper{}.linkerFor(e)
+
+ b := aLinker.Prev()
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ aLinker.SetPrev(e)
if b != nil {
sessionElementMapper{}.linkerFor(b).SetNext(e)
diff --git a/pkg/sentry/kernel/socket_list.go b/pkg/sentry/kernel/socket_list.go
index aed0a555e..a3d47e381 100755
--- a/pkg/sentry/kernel/socket_list.go
+++ b/pkg/sentry/kernel/socket_list.go
@@ -54,8 +54,9 @@ func (l *socketList) Back() *SocketEntry {
// PushFront inserts the element e at the front of list l.
func (l *socketList) PushFront(e *SocketEntry) {
- socketElementMapper{}.linkerFor(e).SetNext(l.head)
- socketElementMapper{}.linkerFor(e).SetPrev(nil)
+ linker := socketElementMapper{}.linkerFor(e)
+ linker.SetNext(l.head)
+ linker.SetPrev(nil)
if l.head != nil {
socketElementMapper{}.linkerFor(l.head).SetPrev(e)
@@ -68,8 +69,9 @@ func (l *socketList) PushFront(e *SocketEntry) {
// PushBack inserts the element e at the back of list l.
func (l *socketList) PushBack(e *SocketEntry) {
- socketElementMapper{}.linkerFor(e).SetNext(nil)
- socketElementMapper{}.linkerFor(e).SetPrev(l.tail)
+ linker := socketElementMapper{}.linkerFor(e)
+ linker.SetNext(nil)
+ linker.SetPrev(l.tail)
if l.tail != nil {
socketElementMapper{}.linkerFor(l.tail).SetNext(e)
@@ -98,10 +100,14 @@ func (l *socketList) PushBackList(m *socketList) {
// InsertAfter inserts e after b.
func (l *socketList) InsertAfter(b, e *SocketEntry) {
- a := socketElementMapper{}.linkerFor(b).Next()
- socketElementMapper{}.linkerFor(e).SetNext(a)
- socketElementMapper{}.linkerFor(e).SetPrev(b)
- socketElementMapper{}.linkerFor(b).SetNext(e)
+ bLinker := socketElementMapper{}.linkerFor(b)
+ eLinker := socketElementMapper{}.linkerFor(e)
+
+ a := bLinker.Next()
+
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ bLinker.SetNext(e)
if a != nil {
socketElementMapper{}.linkerFor(a).SetPrev(e)
@@ -112,10 +118,13 @@ func (l *socketList) InsertAfter(b, e *SocketEntry) {
// InsertBefore inserts e before a.
func (l *socketList) InsertBefore(a, e *SocketEntry) {
- b := socketElementMapper{}.linkerFor(a).Prev()
- socketElementMapper{}.linkerFor(e).SetNext(a)
- socketElementMapper{}.linkerFor(e).SetPrev(b)
- socketElementMapper{}.linkerFor(a).SetPrev(e)
+ aLinker := socketElementMapper{}.linkerFor(a)
+ eLinker := socketElementMapper{}.linkerFor(e)
+
+ b := aLinker.Prev()
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ aLinker.SetPrev(e)
if b != nil {
socketElementMapper{}.linkerFor(b).SetNext(e)
diff --git a/pkg/sentry/kernel/task_list.go b/pkg/sentry/kernel/task_list.go
index 57d3f098d..9b8f07b46 100755
--- a/pkg/sentry/kernel/task_list.go
+++ b/pkg/sentry/kernel/task_list.go
@@ -54,8 +54,9 @@ func (l *taskList) Back() *Task {
// PushFront inserts the element e at the front of list l.
func (l *taskList) PushFront(e *Task) {
- taskElementMapper{}.linkerFor(e).SetNext(l.head)
- taskElementMapper{}.linkerFor(e).SetPrev(nil)
+ linker := taskElementMapper{}.linkerFor(e)
+ linker.SetNext(l.head)
+ linker.SetPrev(nil)
if l.head != nil {
taskElementMapper{}.linkerFor(l.head).SetPrev(e)
@@ -68,8 +69,9 @@ func (l *taskList) PushFront(e *Task) {
// PushBack inserts the element e at the back of list l.
func (l *taskList) PushBack(e *Task) {
- taskElementMapper{}.linkerFor(e).SetNext(nil)
- taskElementMapper{}.linkerFor(e).SetPrev(l.tail)
+ linker := taskElementMapper{}.linkerFor(e)
+ linker.SetNext(nil)
+ linker.SetPrev(l.tail)
if l.tail != nil {
taskElementMapper{}.linkerFor(l.tail).SetNext(e)
@@ -98,10 +100,14 @@ func (l *taskList) PushBackList(m *taskList) {
// InsertAfter inserts e after b.
func (l *taskList) InsertAfter(b, e *Task) {
- a := taskElementMapper{}.linkerFor(b).Next()
- taskElementMapper{}.linkerFor(e).SetNext(a)
- taskElementMapper{}.linkerFor(e).SetPrev(b)
- taskElementMapper{}.linkerFor(b).SetNext(e)
+ bLinker := taskElementMapper{}.linkerFor(b)
+ eLinker := taskElementMapper{}.linkerFor(e)
+
+ a := bLinker.Next()
+
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ bLinker.SetNext(e)
if a != nil {
taskElementMapper{}.linkerFor(a).SetPrev(e)
@@ -112,10 +118,13 @@ func (l *taskList) InsertAfter(b, e *Task) {
// InsertBefore inserts e before a.
func (l *taskList) InsertBefore(a, e *Task) {
- b := taskElementMapper{}.linkerFor(a).Prev()
- taskElementMapper{}.linkerFor(e).SetNext(a)
- taskElementMapper{}.linkerFor(e).SetPrev(b)
- taskElementMapper{}.linkerFor(a).SetPrev(e)
+ aLinker := taskElementMapper{}.linkerFor(a)
+ eLinker := taskElementMapper{}.linkerFor(e)
+
+ b := aLinker.Prev()
+ eLinker.SetNext(a)
+ eLinker.SetPrev(b)
+ aLinker.SetPrev(e)
if b != nil {
taskElementMapper{}.linkerFor(b).SetNext(e)