From ba2ee311005b3175808b8fde4d76509b14efe35a 2012-08-09 14:10:16
From: Puneeth Chaganti <punchagan@gmail.com>
Date: 2012-08-09 14:10:16
Subject: [PATCH] CLN: Use name to id mapping of notebooks instead of searching.

Minor clean-up.

---

diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py
index 4d63bbb..13f13c9 100644
--- a/IPython/frontend/html/notebook/notebookapp.py
+++ b/IPython/frontend/html/notebook/notebookapp.py
@@ -579,13 +579,8 @@ class NotebookApp(BaseIPythonApplication):
                 browser = None
 
             if self.file_to_run:
-                filename, _ = os.path.splitext(os.path.basename(self.file_to_run))
-                for nb in self.notebook_manager.list_notebooks():
-                    if filename == nb['name']:
-                        url = nb['notebook_id']
-                        break
-                else:
-                    url = ''
+                name, _ = os.path.splitext(os.path.basename(self.file_to_run))
+                url = self.notebook_manager.rev_mapping.get(name, '')
             else:
                 url = ''
             if browser: