Repository: AvaloniaUI/Avalonia
File: src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs (C#)

Code before:
                s_intermediatePointsPooledList.Clear();
                s_sortedPoints.Clear();

                s_sortedPoints.Capacity = pointsCount;

                for (int i = 0; i < pointsCount; i++)
                {
                    var mp = movePoints[i];

                    var x = mp.x > 32767 ? mp.x - 65536 : mp.x;
                    var y = mp.y > 32767 ? mp.y - 65536 : mp.y;

                    s_sortedPoints.Add(new InternalPoint
                    {
                        Time = mp.time,
                        Pt = new PixelPoint(x, y)
                    });
                }

                // sorting is required to ensure points are in order from oldest to newest
                s_sortedPoints.Sort(static (a, b) => a.Time.CompareTo(b.Time));

                foreach (var p in s_sortedPoints)
                {
                    // skip newer than current
                    if (p.Time > movePoint.time)
                        continue;

                    // skip older and equal than previous (sometimes fast strokes result in the same time value)
                    if (p.Time <= prevMovePoint.time)
                        continue;

                    var client = PointToClient(p.Pt);

                    s_intermediatePointsPooledList.Add(new RawPointerPoint
                    {
                        Position = client
                    });
                }

                return s_intermediatePointsPooledList;
            }

        }

        private RawPointerEventArgs CreatePointerArgs(IInputDevice device, ulong timestamp, RawPointerEventType eventType, RawPointerPoint point, RawInputModifiers modifiers, uint rawPointerId)
        {
            return device is TouchDevice
                ? new RawTouchEventArgs(device, timestamp, Owner, eventType, point, modifiers, rawPointerId)
                : new RawPointerEventArgs(device, timestamp, Owner, eventType, point, modifiers)
                {

Review comment (suggestion):
Unless I'm missing something, considering that the points are sorted by time, all further points will also be `> movePoint.Time` so we can `break` out of the loop instead.

That said, it might simply be easier (and more performant) to avoid adding points that aren't between `prevModePoint.time` and `movePoint.time` to the `s_sortedPoints` collection.

Code after:
                s_intermediatePointsPooledList.Clear();
                s_sortedPoints.Clear();

                s_sortedPoints.Capacity = pointsCount;

                for (int i = 0; i < pointsCount; i++)
                {
                    var mp = movePoints[i];

                    var x = mp.x > 32767 ? mp.x - 65536 : mp.x;
                    var y = mp.y > 32767 ? mp.y - 65536 : mp.y;

                    if(mp.time <= prevMovePoint.time || mp.time >= movePoint.time)
                        continue;

                    s_sortedPoints.Add(new InternalPoint
                    {
                        Time = mp.time,
                        Pt = new PixelPoint(x, y)
                    });
                }

                // sorting is required to ensure points are in order from oldest to newest
                s_sortedPoints.Sort(static (a, b) => a.Time.CompareTo(b.Time));

                foreach (var p in s_sortedPoints)
                {
                    var client = PointToClient(p.Pt);

                    s_intermediatePointsPooledList.Add(new RawPointerPoint
                    {
                        Position = client
                    });
                }

                return s_intermediatePointsPooledList;
            }

        }

        private RawPointerEventArgs CreatePointerArgs(IInputDevice device, ulong timestamp, RawPointerEventType eventType, RawPointerPoint point, RawInputModifiers modifiers, uint rawPointerId)
        {
            return device is TouchDevice
                ? new RawTouchEventArgs(device, timestamp, Owner, eventType, point, modifiers, rawPointerId)
                : new RawPointerEventArgs(device, timestamp, Owner, eventType, point, modifiers)
                {
                    RawPointerId = rawPointerId
                };
        }

        private void GetDevicePointerInfo(IntPtr wParam,